seaworthy.containers.postgresql¶
PostgreSQL container definition.
-
class
PostgreSQLContainer(name='postgresql', image='postgres:alpine', wait_patterns=('database system is ready to accept connections', 'database system is ready to accept connections'), database='database', user='user', password='password', **kwargs)[source]¶ PostgreSQL container definition.
Todo
Write more docs.
-
base_kwargs()[source]¶ Add a
tmpfsentry for/var/lib/postgresql/datato avoid unnecessary disk I/O andenvironmententries for the configured db and user creds.
-
clean()[source]¶ Remove all data by dropping and recreating the configured database.
Note
Only the configured database is removed. Any other databases remain untouched.
-
database_url()[source]¶ Returns a “database URL” for use with DJ-Database-URL and similar libraries.
-
exec_pg_success(cmd)[source]¶ Execute a command inside a running container as the postgres user, asserting success.
-
exec_psql(command, psql_opts=['-qtA'])[source]¶ Execute a
psqlcommand inside a running container. By default the container’s database is connected to.Parameters: - command – the command to run (passed to
-c) - psql_opts – a list of extra options to pass to
psql
Returns: a tuple of the command exit code and output
- command – the command to run (passed to
-
list_databases()[source]¶ Runs the
\listcommand and returns a list of column values with information about all databases.
-