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.

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.

Install: pip install gnomon-postgres (extras: sqlalchemy, django, test).

Metadata

Release files for gnomon-postgres 1.0.1

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.1
File Size Uploaded Provenance Actions
gnomon_postgres-1.0.1.tar.gz 29.6 kB With provenance Details for gnomon_postgres-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 58.0 kB

Release files / gnomon_postgres-1.0.1.tar.gz

Download URL gnomon_postgres-1.0.1.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a5a54cd77e36b34603a465190f44824123e051d0e27f3d9af49e37da44d43ae7
BLAKE2b-256 checksum
How to use checksums
bc021dc37dab1e2ab6ffa086294d0001629a90897d2ffe6f1750969e3d84d29d
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 13, 2026.

Transparency log

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

Download URL gnomon_postgres-1.0.1-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7d87426d6300afb89264d9d5ee01b5d00fa11e0da416b45217ebaf2f24fd684
BLAKE2b-256 checksum
How to use checksums
9441af26ed5d45e02683b5c9b14f7fd8616f927eb6701d79b250a8a956e2a873
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 13, 2026.

Transparency log

Security for gnomon-postgres 1.0.1

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.1.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 13, 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