Skip to main content

xlambda-postgres

Managed PostgreSQL: provisioning, sub-users, backups, and a get_pool() convenience.

pip install xlambda-postgres          # provisioning only
pip install "xlambda-postgres[pool]"  # plus psycopg, for get_pool()

Python port of @xlambda-tech/postgres.

Provisioning

from xlambda.postgres import PostgresClient

client = PostgresClient(api_key=os.environ["XLAMBDA_API_KEY"])

db = client.databases.create(project_id="proj_123", name="app", tier="starter")
db["connectionString"]   # shown here and on rotate/reveal only

create(), rotate_password(), and reveal_connection() return a DatabaseHandle — a plain dict subclass, so every response field reads normally, with pool constructors added on top:

pool = db.get_pool()                  # port 6432, PgBouncer transaction pooling
migrations = db.get_session_pool()    # port 6433, direct session

async_pool = db.get_async_pool()      # psycopg_pool.AsyncConnectionPool

Which port matters. 6432 is transaction-pooled and is what steady-state app traffic should use; its connection string carries ?pgbouncer=true, which disables client-side prepared statements because transaction pooling breaks them. Use 6433 for migrations, DDL, advisory locks, and anything else needing a real session.

reveal_connection() discloses the current password rather than changing it. It 404s for instances that predate the feature or were created without CONSOLE_CREDENTIAL_ENCRYPTION_KEY configured — rotate to recover in that case.

Sub-users and backups

user = client.databases.users(db["id"]).create(permission="readonly", expires_at="2027-01-01T00:00:00Z")
user["password"]     # shown once

backups = client.databases.backups(db["id"])
backups.create()
backups.restore("bkp_123")   # overwrites all current data; cannot be undone

What this doesn't wrap

The dashboard's own SQL console. Running queries isn't something the REST API mediates — there's no app-facing /v1/databases/:id/query route — so once a database is provisioned you talk to it with psycopg through the handle above. get_pool() is a thin ergonomic wrapper around psycopg_pool, not a reimplementation of it, and psycopg stays an optional extra so provisioning-only callers don't install a driver they never use.

Async

from xlambda.postgres import AsyncPostgresClient

async with AsyncPostgresClient(api_key=...) as client:
    db = await client.databases.create(project_id="proj_123", name="app")

Conventions

Arguments are snake_case; responses are the API's own camelCase, returned as plain dicts typed by TypedDict. Byte counts that are bigints server-side (storageQuotaBytes, storageBytes, backup sizeBytes) arrive as strings rather than losing precision in JSON. See xlambda-core.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xlambda_postgres-0.2.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xlambda_postgres-0.2.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file xlambda_postgres-0.2.0.tar.gz.

File metadata

  • Download URL: xlambda_postgres-0.2.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for xlambda_postgres-0.2.0.tar.gz
Algorithm Hash digest
SHA256 39729f5f9cb0debc4548edc2d1e4d1f952cf0d54138f595d69cc339552408faf
MD5 31103b713884e2f4ede38b34e4a44d9b
BLAKE2b-256 eec23c5f1492e61de79edf82389d76349f611a255d60d6f878a64f7e681cc054

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlambda_postgres-0.2.0.tar.gz:

Publisher: sdk-release-python.yml on randyryan177-cloud/media-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xlambda_postgres-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xlambda_postgres-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd3095830e9d4c6fe2b77b346379ce52929687f804e01ece65817532a09c3063
MD5 eb77ce30ee4f613ef63070c55744b420
BLAKE2b-256 fd872cb7c2511c4db4d5048ee8e0848c53434ad8eec13c73d249e55ba6b0df8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for xlambda_postgres-0.2.0-py3-none-any.whl:

Publisher: sdk-release-python.yml on randyryan177-cloud/media-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page