Skip to content

postgres

etl_craft.dialects.engine.postgres

PostgreSQL: the recommended Engine DB for production, shared by every worker.

PostgresEngineDialect

Bases: EngineDialect

PostgreSQL: transactional DDL and advisory locks.

refresh_metadata_triggers

refresh_metadata_triggers(conn: Connection) -> None

Install this database's metadata capture and write guards.

build_engine

build_engine(config: ConnectorConfig, profile: ConnectionProfile, **engine_kwargs: Any) -> Engine

Build the engine through psycopg; the password never appears in its URL.

Every new connection authenticates afresh, so a minted credential (oauth, sts) is current; pooled connections using one are recycled before it expires.

schema_problem

schema_problem(conn: Connection, schema: str) -> str | None

Return why the Engine schema cannot be used: it must already exist.

lock

lock(engine: Engine, key: int, name: str, wait_seconds: float = 0) -> Iterator[None]

Hold a transaction-scoped advisory lock, on a connection of its own.

The lock ends with that connection's transaction, so it is released even when the holder's process dies. The caller's own work runs on other connections.

parse_postgres_url

parse_postgres_url(jdbc_url: str) -> JdbcUrl

Split a jdbc:postgresql://host[:port]/database[?query] URL; the port defaults to 5432.

The query string is kept, so sslmode=require reaches the driver.

psycopg_auth_kwargs

psycopg_auth_kwargs(auth_mode: str, *, user: str, secret: str, extra: Mapping[str, Any], host: str, port: int) -> dict[str, Any]

Return the psycopg connect arguments that authenticate user by auth_mode.

Shared by the Engine DB and the PostgreSQL warehouse, so they authenticate the same way. Called once per new connection, which keeps a minted credential current.

postgres_creator

postgres_creator(profile: ConnectionProfile, secret: str, url: JdbcUrl) -> Callable[[], Any]

Return a function that opens one authenticated psycopg connection for profile.