Skip to main content

gnomon-postgres (Python)

Branches, time travel and merges for PostgreSQL apps on the gnomon extension: the SDK (runs for agents and tasks, review, the core), psycopg helpers, SQLAlchemy and Django, and pytest fixtures with snapshots. import gnomon.

Install

pip install gnomon-postgres

Python 3.9 or later. Extras: sqlalchemy, django, asyncpg and test (the pytest plugin), as in pip install "gnomon-postgres[sqlalchemy]". It connects through psycopg 3, which needs libpq; on a machine without it, add "psycopg[binary]".

A run

from gnomon import Gnomon

gn = Gnomon(app="dbname=shop user=shop_app", runs="dbname=shop user=shop_runs")
with gn.start_run("Refund order 3", actor="support-bot") as run:   # a branch for this task
    run.sql("update orders set status = 'refunded' where id = 3")
    if run.summary()["checks"]["passed"]: run.merge()
    else: run.submit("Refund order 3")                               # a change request instead

Leaving the with block without merge() or submit() discards the branch. run.url(base) and run.connection(base) give a tool a connection string, or a psycopg connection, pinned to the run (a login of the run's own, confined to its branch, dropped when the run ends). With asyncpg: AsyncGnomon(app=asyncpg_source(pool), runs=asyncpg_source(runs_pool)) (from gnomon.asyncpg import asyncpg_source; the asyncpg extra). AsyncGnomon is the same API for psycopg.AsyncConnection (the sync client is generated from it, so they cannot drift). gn.requests, gn.branches, history, blame, revert, status() and doctor() are the review and core layers. Tools for agent frameworks bound to one run: gnomon.tools.anthropic_tools(run), openai_agents_tools(run), langchain_tools(run), mcp_handler(run). The two logins, the envelope and the errors are as in the TypeScript SDK (the TypeScript SDK); both pass the same conformance scenarios (the specification).

Helpers

import gnomon, psycopg
conn = psycopg.connect(gnomon.branch_dsn("dbname=shop", "feature"))   # sessions start on a branch
with gnomon.branch(conn, "feature"): ...                               # or switch one connection
opts = gnomon.connection_options(admin_conn, "feature")                # what the database says the
                                                                       # branch needs (schema versions, masks)

use, begin (one transaction, for poolers), create_branch, create_scratch, drop_branch, diff, merge. SQLAlchemy: gnomon.sqlalchemy.branch_engine(url, branch) and attach_branch(engine, get_branch) (each transaction on the branch a callable names). Django: gnomon.django.BranchMiddleware (a branch per request from X-Gnomon-Branch).

Tests on branches

def test_signup(gnomon_conn, gnomon_snapshot):     # a psycopg connection on a fresh scratch branch
    signup(gnomon_conn, "a@x.io")
    gnomon_snapshot.assert_match(gnomon_conn)      # the branch's diff against a stored file

GNOMON_TEST_DSN=... pytest (the plugin loads itself when the package is installed; --gnomon-update-snapshots records, --gnomon-keep keeps the branches). gnomon.testing.assert_no_changes and assert_changed check a branch's diff directly.

Metadata

Release files for gnomon-postgres 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gnomon-postgres 1.0.2
File Size Uploaded Provenance Actions
gnomon_postgres-1.0.2.tar.gz 29.8 kB With provenance Details for gnomon_postgres-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gnomon-postgres 1.0.2
File Interpreter ABI Platform Actions
gnomon_postgres-1.0.2-py3-none-any.whl Python 3 none any Details for gnomon_postgres-1.0.2-py3-none-any.whl

Total release size: 58.3 kB

Release files / gnomon_postgres-1.0.2.tar.gz

Download URL gnomon_postgres-1.0.2.tar.gz
Size 29.8 kB
Tags Source
SHA-256 checksum
How to use checksums
762d93305761d35eef29016fe46f5c5c6e584d11e5835b0d97bfed9f9813f1a6
BLAKE2b-256 checksum
How to use checksums
1ae1c2cc670bec674bfbb5887ae894e4c5d0325680cf1f43b2570f80772b664a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / gnomon_postgres-1.0.2-py3-none-any.whl

Download URL gnomon_postgres-1.0.2-py3-none-any.whl
Size 28.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be1ee13ba2708416a798406b1e0ac1d46d45ba8c0b29c2eca5f3f72ca924a306
BLAKE2b-256 checksum
How to use checksums
40a684a898720f5ec5e404cdee4e00d388525b8635f7fa8fa33b98e023950ed8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for gnomon-postgres 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gnomon_postgres-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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