Cloud & Managed Postgres#
pgdorm is all-in on modern PostgreSQL. Every managed, serverless, and lakehouse-attached PostgreSQL service that runs genuine upstream PostgreSQL works natively — including 1-RTT pipelining, UNNEST WITH ORDINALITY, RETURNING OLD/NEW, MERGE, uuidv7(), WITHOUT OVERLAPS, Row-Level Security, Arrow COPY BINARY, and online migrations.
Because pgdorm-wire speaks the PostgreSQL v3 binary protocol directly in Rust, cloud compatibility comes down to two things:
- Engine reality — does the service run genuine upstream PostgreSQL underneath (verified automatically by
pgdorm doctor), or is it a wire-protocol rewrite? - Transport & auth hygiene — TLS (
sslmode=preferby default),SCRAM-SHA-256-PLUSchannel binding, OS root CAs (sslrootcert=system), mTLS (sslcert/sslkey),options=,connect_timeout, dynamic IAM/OAuthpassword=callbacks, andpool_mode=pg.enums.PoolMode.TRANSACTIONfor cloud poolers.
Verify Your Database in One Command (pgdorm doctor)#
Before migrating any application code, point pgdorm doctor at your cloud database (read-only by default; add --write-probe to also test pg_temp, UNNEST, and RETURNING OLD/NEW inside an immediately rolled-back transaction):
Behind a transaction pooler (Neon -pooler, Supabase Supavisor, AWS RDS Proxy, Azure PgBouncer):
(If running from a source clone of this repository, prefix commands with uv run --no-sync.)
For CI pipelines, pass --json (exits 0 when all checks pass, 1 on failure) or call await pg.doctor(pool, write_probe=True) from Python.
Compatibility Matrix (3 Architectural Tiers)#
Tier 1 — Compatible (Upstream PostgreSQL)#
All of these run genuine upstream PostgreSQL backends (some with decoupled storage, serverless scale-to-zero, NVMe/CDC bridges, or managed connection poolers). Local CI exercises upstream PostgreSQL and PgBouncer on every push; run pgdorm doctor --write-probe or -m cloud_smoke against your own cloud instance to verify server compatibility (and optional extension allow-lists like btree_gist if you use temporal WITHOUT OVERLAPS keys):
| Provider | Notes & Connection Profile |
|---|---|
| AWS RDS for PostgreSQL | Direct (pool_mode=pg.enums.PoolMode.DIRECT), ?sslmode=verify-full&sslrootcert=<rds-ca.pem>, optional IAM password= factory |
| Amazon Aurora PostgreSQL | Same as RDS; multi-host writer,reader?target_session_attrs=read-write or prefer-standby + connect_timeout=5 |
| AWS RDS Proxy | pool_mode=pg.enums.PoolMode.TRANSACTION, prepared_statements=False (avoids proxy session pinning), IAM password= factory |
| Google Cloud SQL | Cloud SQL Auth Proxy (Unix socket ?host=/cloudsql/... or localhost TCP), or direct mTLS (sslcert/sslkey) + IAM |
| Google AlloyDB / AlloyDB Omni | Native PostgreSQL; same transport options as Cloud SQL (google/alloydbomni available for local Docker) |
| Azure Database for PostgreSQL (Flexible Server) | Direct or built-in PgBouncer (pool_mode=pg.enums.PoolMode.TRANSACTION), ?sslmode=verify-full&sslrootcert=system, Entra ID password= factory |
| Databricks Lakebase / Neon | Default copy-paste DSN (?sslmode=require&channel_binding=require, optional options=endpoint=...) works out of the box; use pool_mode=pg.enums.PoolMode.TRANSACTION on -pooler hostnames and password= factory for Databricks OAuth |
| Snowflake Postgres (Crunchy Data) | Upstream PostgreSQL support; ?sslmode=verify-full&sslrootcert=system, pool_mode=pg.enums.PoolMode.TRANSACTION when using pooled endpoint |
| ClickHouse Managed Postgres (Ubicloud) | Genuine Postgres on NVMe/CDC; ?sslmode=verify-full&sslrootcert=system, pool_mode=pg.enums.PoolMode.TRANSACTION if pooled |
| Supabase | Direct port 5432 (pool_mode=pg.enums.PoolMode.DIRECT) or Supavisor port 6543 (pool_mode=pg.enums.PoolMode.TRANSACTION, prepared_statements=False) |
| TigerData (formerly Timescale) | PostgreSQL + TimescaleDB extensions (timescale/timescaledb:latest-pg18 Docker image supported via --pg-image) |
| CloudNativePG / Crunchy PGO (K8s) | Multi-host rw,ro?target_session_attrs=read-write + mTLS (sslcert/sslkey) + PgBouncer pooler support |
| PlanetScale Postgres, Aiven, DigitalOcean, Render, Railway | Standard PostgreSQL DSNs with ?sslmode=verify-full&sslrootcert=system (or provider CA PEM) |
Tier 2 — PG-Forked Distributed Engines (Tracks Upstream PG)#
| Engine | Status |
|---|---|
| YugabyteDB (YSQL) | Reuses a forked PostgreSQL query layer, but tracks an older upstream PostgreSQL major version below pgdorm's baseline (pgdorm doctor checks this at handshake). |
| Citus | Sharded PostgreSQL extension; supported on current upstream PostgreSQL builds (note distributed-table FK/DDL rules from Citus apply). |
Tier 3 — Wire-Protocol Rewrites (Explicitly Unsupported)#
All-in on genuine PostgreSQL
pgdorm intentionally does not support PostgreSQL wire-protocol emulators such as CockroachDB, Amazon Aurora DSQL, or Google Cloud Spanner (PGAdapter). Supporting them would require giving up core pgdorm guarantees: FK-enforced joins (JOIN USING), range types and TemporalPrimaryKey (WITHOUT OVERLAPS / btree_gist, which also requires btree_gist to be installable/allow-listed on managed services), pg_temp staging + MERGE, binary COPY Arrow transfers, pg_catalog online migrations, and RETURNING OLD/NEW.
Provider Connection Recipes#
Neon & Databricks Lakebase#
Neon's default connection string (including channel_binding=require and SCRAM-SHA-256-PLUS) works unmodified:
# Pooled serverless endpoint (`-pooler` hostname)
pool = await pg.Pool.connect(
"postgresql://user:[email protected]/neondb"
"?sslmode=require&channel_binding=require",
pool_mode=pg.enums.PoolMode.TRANSACTION,
)
For Databricks Lakebase OAuth token rotation, pass an async password= factory paired with max_lifetime:
async def lakebase_oauth_token() -> str:
# Call your Databricks SDK credential helper to mint a fresh OAuth token
return await fetch_databricks_pg_token()
pool = await pg.Pool.connect(
"postgresql://[email protected]/app"
"?sslmode=verify-full&sslrootcert=system",
password=lakebase_oauth_token,
max_lifetime=2700.0, # recycle connections before 60-minute OAuth expiry
)
AWS RDS, Aurora & RDS Proxy (with IAM Auth)#
Pool.connect(..., password=callable) invokes your sync or async token generator every time a new physical connection is opened — no AWS SDK dependency is required inside pgdorm:
import boto3
rds = boto3.client("rds", region_name="eu-central-1")
def rds_iam_token() -> str:
return rds.generate_db_auth_token(
DBHostname="dorm-cluster.cluster-abc.eu-central-1.rds.amazonaws.com",
Port=5432,
DBUsername="app_iam",
)
# Direct Aurora writer/reader failover with RDS Global CA bundle
pool = await pg.Pool.connect(
"postgresql://[email protected],reader.rds.amazonaws.com/dorm"
"?sslmode=verify-full&sslrootcert=/etc/ssl/rds-global-bundle.pem"
"&target_session_attrs=read-write&connect_timeout=5",
password=rds_iam_token,
max_lifetime=600.0, # rotate before 15-minute IAM token TTL
)
# Behind AWS RDS Proxy: avoid backend pinning by disabling named prepared statements
proxy_pool = await pg.Pool.connect(
"postgresql://[email protected]/dorm"
"?sslmode=verify-full&sslrootcert=/etc/ssl/rds-global-bundle.pem",
password=rds_iam_token,
pool_mode=pg.enums.PoolMode.TRANSACTION,
prepared_statements=False,
max_lifetime=600.0,
)
Google Cloud SQL & AlloyDB#
- Via Cloud SQL Auth Proxy (Unix socket):
pool = await pg.Pool.connect(
"postgresql://app_user:secret@/dorm?host=/cloudsql/my-proj:europe-west1:dorm-pg",
)
- Direct mTLS + IAM token:
pool = await pg.Pool.connect(
"postgresql://[email protected]:5432/dorm"
"?sslmode=verify-ca&sslrootcert=/certs/server-ca.pem"
"&sslcert=/certs/client-cert.pem&sslkey=/certs/client-key.pem",
password=fetch_gcp_iam_token,
max_lifetime=2700.0,
)
Azure Database for PostgreSQL (Flexible Server)#
pool = await pg.Pool.connect(
"postgresql://[email protected]:5432/dorm"
"?sslmode=verify-full&sslrootcert=system",
password=fetch_entra_id_token,
pool_mode=pg.enums.PoolMode.TRANSACTION, # when using built-in PgBouncer on port 6432
max_lifetime=2700.0,
)
Snowflake Postgres (Crunchy Data) & ClickHouse Managed Postgres (Ubicloud)#
pool = await pg.Pool.connect(
"postgresql://app_user:[email protected]:5432/app"
"?sslmode=verify-full&sslrootcert=system&connect_timeout=10",
pool_mode=pg.enums.PoolMode.DIRECT, # switch to "transaction" on pooled endpoints
)
Supabase (Direct vs Supavisor)#
# Direct connection (port 5432): full session features + LISTEN/NOTIFY
direct = await pg.Pool.connect(
"postgresql://postgres:[email protected]:5432/postgres"
"?sslmode=verify-full&sslrootcert=system",
)
# Supavisor transaction pooler (port 6543)
pooled = await pg.Pool.connect(
"postgresql://postgres.projectref:[email protected]:6543/postgres"
"?sslmode=require",
pool_mode=pg.enums.PoolMode.TRANSACTION,
prepared_statements=False,
)
Running the Conformance Suite Against Your Own Cloud DB#
pgdorm ships a portable @pytest.mark.cloud_smoke conformance suite in this repository (requires cloning the repo; tests/ is excluded from the published wheel) that isolates every test inside a temporary t_<hex> schema and requires zero superuser privileges:
You can also run the local Docker suite against any vendor-packaged PostgreSQL Docker image using --pg-image:
← PreviousBuilding Libraries on pgdormRegistries, Protocols, Migrations & Testing