PostgreSQLContext

class felis.db.database_context.PostgreSQLContext(engine_url, metadata)

Bases: _BaseContext

Database context for Postgres.

Parameters:
  • engine_url (URL) – The SQLAlchemy database URL for connecting to the database.

  • metadata (MetaData) – The SQLAlchemy metadata representing the database objects.

Attributes Summary

DIALECT

Methods Summary

drop()

Drop the schema in the database if it exists.

initialize()

Create the target schema in the database if it does not exist already.

Attributes Documentation

DIALECT: str = 'postgresql'

Methods Documentation

drop()

Drop the schema in the database if it exists.

Implementations should use IF EXISTS semantics to avoid raising an error if the schema does not exist.

Raises:

DatabaseContextError – If there is an error dropping the schema.

Return type:

None

initialize()

Create the target schema in the database if it does not exist already.

Sub-classes should implement idempotent behavior so that calling this method multiple times has no adverse effects. If the schema already exists, the method should simply return without raising an error. (A warning message may be logged in this case.)

Raises:

DatabaseContextError – If there is an error instantiating the schema.

Return type:

None