Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sendproof-sqlalchemy

Rollback previews, SQL capture and ORM change capture for Sendproof applications that use SQLAlchemy 2.x.

from sendproof_sqlalchemy import SQLAlchemyPreview

provider = SQLAlchemyPreview(engine, database="inventory_dev")   # Engine or AsyncEngine

Pass the provider to a framework adapter, for example Sendproof(app, provider=provider, ...). Install sendproof-sqlalchemy[asyncio] for AsyncEngine support (needs greenlet). database is a public label; never put a connection string in it.

What a preview guarantees

While a preview runs, every Session and Connection of the request that uses a registered engine shares one database connection. A hook on the engine's raw_connection() provides it only inside a preview; other requests are untouched. On that connection:

  • commit releases an internal SAVEPOINT, so the writes stay visible to the rest of the request (commit-then-refresh, a second Session in a dependency, and so on) but are never durable.
  • rollback rolls back to that savepoint, so a handler that commits and then fails behaves as it would for real.
  • At the end the adapter performs a real rollback and confirms it. If the database refuses, the adapter withholds the success envelope and the connection is invalidated rather than reused.

An independent read after the preview, from a separate request or connection, finds the data unchanged.

Change capture

Inserts, updates and deletes flushed through the ORM Session become changes with the table, the primary key and before/after column snapshots (keys use column names). Observed Send records the same changes while committing normally.

Coverage notes

Read these before advertising an operation for Preview.

  • Not captured: Core DML (session.execute(update(...))), ORM bulk operations, raw SQL, database triggers and cascades performed by the database. Their SQL appears in the logs and they are still rolled back, but no rows are shown. Rows are never synthesized.

  • One connection per engine: statements that run concurrently inside a single preview share a connection and its locks. With SQLite, two previews at once block each other until the first rolls back; PostgreSQL and MySQL do not.

  • Verified dialects: SQLite, PostgreSQL and MySQL. The ANSI savepoint path also permits MariaDB and Oracle, which have yet to be exercised by the conformance matrix. Other dialects make Preview unavailable.

  • Refused: engines or connections in AUTOCOMMIT mode, because the driver commits each statement itself.

  • Transaction-control SQL is refused before it is sent: COMMIT, ROLLBACK (but not ROLLBACK TO SAVEPOINT), BEGIN, SET autocommit in any form, XA, and the internal sendproof_preview savepoint. On MySQL and MariaDB also every implicitly committing statement (DDL other than TEMPORARY tables, LOCK/UNLOCK TABLES, GRANT, REVOKE, ANALYZE, CHECK, OPTIMIZE, REPAIR and CACHE INDEX on tables, SET PASSWORD, replication control), SQL-level PREPARE and EXECUTE (and MariaDB's EXECUTE IMMEDIATE), executable comments (/*! ... */) that contain any of these, and CALL. The Preview then answers 500 and rolls back.

  • Stored procedures (MySQL and MariaDB): a procedure can COMMIT, so CALL is refused unless you declare the procedure safe by exact name:

    SQLAlchemyPreview(engine, safe_procedures=["refresh_totals", "reports.rebuild_cache"])
    

    Names are exact (a schema-qualified call needs the qualified name) and, like MySQL, case-insensitive; wildcards are rejected. This is your statement that the procedure never commits: the binding trusts it.

  • Backstop (every database): the Preview opens its transaction with SAVEPOINT sendproof_preview and, before rolling back, rolls back to it. Any commit erases it, so if something committed anyway (a declared procedure that does commit, a driver call around the engine, after which the driver opens a new transaction by itself), the Preview answers 500 without confirmation, whatever the handler returned. A handler's RELEASE or ROLLBACK TO of that savepoint is refused. The writes made before that commit are durable; the check only stops the Preview from claiming otherwise.

  • Deadlocks (MySQL and MariaDB): a deadlock (1213), or a lock wait timeout (1205) with innodb_rollback_on_timeout on, rolls back the whole Preview transaction. The handler still gets the original error, but every later statement in that Preview is refused before it is sent (a retry would run outside the transaction, and with autocommit on commit for real), and the Preview answers 500 without confirmation. The lock wait timeout case shares the deadlock code path and is covered by unit tests only, because innodb_rollback_on_timeout can be set only at server startup.

  • Outside the database: caches, files, other services, other engines you did not register and work queued after the response are not rolled back. Sequences may advance.

  • Connections the application holds across requests are not enrolled.

  • Other engines you registered are enrolled separately but are not coordinated, as with any non-distributed transaction.

Redaction

SQL parameter values are shown only in the Development environment (override with the adapter's include_sql_parameter_values). A parameter whose name contains a secret word (password, secret, token, hash, salt, credential, apikey, or key after api, private, secret, access, signing, encryption, client) shows [REDACTED]. If the statement itself mentions such a word, every value in it is hidden.

Metadata

Release files for sendproof-sqlalchemy 0.1.0a1

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

Source distribution (sdist)

Source distribution for sendproof-sqlalchemy 0.1.0a1
File Size Uploaded Provenance Actions
sendproof_sqlalchemy-0.1.0a1.tar.gz 12.9 kB With provenance Details for sendproof_sqlalchemy-0.1.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sendproof-sqlalchemy 0.1.0a1
File Interpreter ABI Platform Actions
sendproof_sqlalchemy-0.1.0a1-py3-none-any.whl Python 3 none any Details for sendproof_sqlalchemy-0.1.0a1-py3-none-any.whl

Total release size: 28.7 kB

Release files / sendproof_sqlalchemy-0.1.0a1.tar.gz

Download URL sendproof_sqlalchemy-0.1.0a1.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d09d5ab53f3473b25a70d6cb639184bf7e22a512f190fb933accbcc211f27228
BLAKE2b-256 checksum
How to use checksums
b4dabd6edea27c6a5551aa58ccd5f72eecba43653b2f2f8db46b99f26c7f3223
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 22, 2026.

Transparency log

Release files / sendproof_sqlalchemy-0.1.0a1-py3-none-any.whl

Download URL sendproof_sqlalchemy-0.1.0a1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10de4711bb20390058c814c6a16a4ee528c42ae38938727affe6ed3bc8709d76
BLAKE2b-256 checksum
How to use checksums
097fd0e42e9883731968ae97e1e51f1c7fd8a9ac7edb851a4de8683ee86a4115
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 22, 2026.

Transparency log

Security for sendproof-sqlalchemy 0.1.0a1

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 sendproof_sqlalchemy-0.1.0a1.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 22, 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