Skip to main content

Python SQLite Change Data Capture (CDC) and JSONL Changefeed

Capture SQLite row changes transactionally and apply them to peer databases with resumable cursors. This Python library uses SQLite triggers to store typed after-images and old primary keys; a row update and its feed event commit or roll back together. JSON Lines events support caller-managed transport for local-first applications.

Install from source

Requires Python 3.10 or newer and SQLite 3.24+ with JSON functions enabled:

git clone https://github.com/buxerr/sqlite-changefeed.git
cd sqlite-changefeed
python -m pip install .

Capture and apply changes

Register the same persistent table schema on source and peer databases. The example below moves events directly; in an application, send the serialized records over your own transport.

import sqlite3
from sqlite_changefeed import ChangeEvent, Changefeed

source_db = sqlite3.connect("source.db")
peer_db = sqlite3.connect("peer.db")
for db in (source_db, peer_db):
    db.execute("CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, text TEXT NOT NULL)")
    db.commit()

source = Changefeed(source_db)
peer = Changefeed(peer_db)
source.register_table("notes")
peer.register_table("notes")

source_db.execute("INSERT INTO notes (id, text) VALUES (?, ?)", (1, "hello"))
source_db.commit()

batch = source.read_events(after_seq=0, limit=100)
wire_records = [event.to_json() for event in batch]
peer.apply_events([ChangeEvent.from_json(record) for record in wire_records])

Store each source feed ID and last sequence for your transport cursor, then resume with read_events(after_seq=cursor). The receiver persists last_applied(source_feed_id) atomically with row application, so re-delivery is safe. Once every peer acknowledges a sequence, call prune_events(through_seq) to reclaim history.

Schema and replication rules

Register persistent tables with explicit primary keys and at most 100 columns. Peers must use matching registered columns and primary-key definitions. After a table migration, call refresh_table(table, discard_history=True) only after peers have synchronized or been reset; it discards old local events and rewrites the trigger payload shape.

If a database file is cloned to create another device, call rotate_identity() on the clone before it emits changes. This assigns a distinct source ID and clears copied local event history. Trigger events capture row images; they do not preserve original SQL statements, rowid values, or foreign-key ordering policy.

Scope and limitations

The transport is caller-supplied. The library does not open sockets, encrypt events, delete old feed rows automatically, or choose a conflict policy. A target that rejects any row rolls back the complete batch and leaves its cursor unchanged. This is a row changefeed for cooperating SQLite databases, not a general-purpose multi-master conflict-resolution engine.

Run the Python unit suite with PYTHONPATH=src python -m unittest discover -s tests -v.

License

MIT. See LICENSE.

Metadata

Release files for sqlite-changefeed 0.1.0

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

Source distribution (sdist)

Source distribution for sqlite-changefeed 0.1.0
File Size Uploaded Provenance Actions
sqlite_changefeed-0.1.0.tar.gz 13.0 kB With provenance Details for sqlite_changefeed-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlite-changefeed 0.1.0
File Interpreter ABI Platform Actions
sqlite_changefeed-0.1.0-py3-none-any.whl Python 3 none any Details for sqlite_changefeed-0.1.0-py3-none-any.whl

Total release size: 24.0 kB

Release files / sqlite_changefeed-0.1.0.tar.gz

Download URL sqlite_changefeed-0.1.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b3098abe395a7f4d28e0df8d84163609a175c0f730f74b540805a91de24c82ba
BLAKE2b-256 checksum
How to use checksums
1f58b97cda8b28031eefda23dbb950e38b7bd85c5696692d500492200dbf8df2
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 21, 2026.

Transparency log

Release files / sqlite_changefeed-0.1.0-py3-none-any.whl

Download URL sqlite_changefeed-0.1.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ab7a785b895f8531d2a4be367a08edaa9e157793ba4a749412b1c4db1fcb35f
BLAKE2b-256 checksum
How to use checksums
0c34f6867403b53dffc4054ec1aa34ace204b6bc7ac6c60576f01472b2adc971
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 21, 2026.

Transparency log

Security for sqlite-changefeed 0.1.0

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 sqlite_changefeed-0.1.0.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 21, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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