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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39729f5f9cb0debc4548edc2d1e4d1f952cf0d54138f595d69cc339552408faf
|
|
| MD5 |
31103b713884e2f4ede38b34e4a44d9b
|
|
| BLAKE2b-256 |
eec23c5f1492e61de79edf82389d76349f611a255d60d6f878a64f7e681cc054
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xlambda_postgres-0.2.0.tar.gz -
Subject digest:
39729f5f9cb0debc4548edc2d1e4d1f952cf0d54138f595d69cc339552408faf - Sigstore transparency entry: 2743388417
- Sigstore integration time:
-
Permalink:
randyryan177-cloud/media-server@52f9f31ba1bd54d30231faecd72325166d087444 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/randyryan177-cloud
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release-python.yml@52f9f31ba1bd54d30231faecd72325166d087444 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file xlambda_postgres-0.2.0-py3-none-any.whl.
File metadata
- Download URL: xlambda_postgres-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd3095830e9d4c6fe2b77b346379ce52929687f804e01ece65817532a09c3063
|
|
| MD5 |
eb77ce30ee4f613ef63070c55744b420
|
|
| BLAKE2b-256 |
fd872cb7c2511c4db4d5048ee8e0848c53434ad8eec13c73d249e55ba6b0df8f
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xlambda_postgres-0.2.0-py3-none-any.whl -
Subject digest:
cd3095830e9d4c6fe2b77b346379ce52929687f804e01ece65817532a09c3063 - Sigstore transparency entry: 2743388447
- Sigstore integration time:
-
Permalink:
randyryan177-cloud/media-server@52f9f31ba1bd54d30231faecd72325166d087444 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/randyryan177-cloud
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release-python.yml@52f9f31ba1bd54d30231faecd72325166d087444 -
Trigger Event:
workflow_dispatch
-
Statement type: