Universal SQLite Synchronization Core - A dependency-grade, local-first, offline-first SQLite synchronization primitive
Project description
sqlite-sync-core
A production-grade, turn-key synchronization system for SQLite.
sqlite-sync-core provides a powerful, local-first synchronization engine that works seamlessly across multi-peer networks. It handles the "hard parts" of sync (vector clocks, causality, delta bundles, and conflict resolution) while providing a simple, turn-key interface for developers.
๐ Turn-Key Synchronization
You can launch a full synchronization node in one command. No infrastructure required.
16-Second Setup (CLI)
# Install the package
pip install sqlite-sync-core
# Start a node and sync the 'tasks' table automatically
sqlite-sync start --db app.db --name Device-A --tables tasks
Automatic Multi-Peer Sync
Nodes automatically discover each other on the local network (P2P) and synchronize state in the background without any manual peer configuration.
๐๏ธ Enterprise Features
- Multi-Peer Orchestration: Automatically scales sync across N devices.
- P2P Discovery: Zero-config peer-to-peer discovery on LAN.
- Automatic Resolution: Configurable strategies like Last-Write-Wins and Field-Level Merge.
- Schema Evolution: Built-in migrations that sync across the network.
- Transport Agnostic: Works over HTTP, WebSockets, or file transfer.
Technical Usage (Library)
Initialize a Node in Code
from sqlite_sync import SyncNode
node = SyncNode(
db_path="app.db",
device_name="MobileApp",
sync_interval=10 # Sync every 10 seconds
)
await node.start()
node.enable_sync_for_table("users")
Safe Schema Migrations
# Safely add a column that will sync to all other peers
sqlite-sync migrate --db app.db --table tasks --add-column priority --type INTEGER
Core Invariants
| # | Invariant | Description |
|---|---|---|
| 1 | Causal consistency | Vector clocks ensure the correct order of operations. |
| 2 | Deterministic Replay | Identical sets of operations always result in identical state. |
| 3 | Conflict Tolerance | Detects and resolves conflicts explicitly and safely. |
| 4 | Offline-First | Entirely local-first design; works without cloud or internet. |
2. Generate a Delta Bundle
# To be sent to Peer B
bundle_path = engine.generate_bundle(
peer_device_id=peer_b_id,
output_path="delta.db"
)
3. Import and Detect Conflicts
# On Peer B
result = engine.import_bundle("delta.db")
print(f"Ops Applied: {result.applied_count}")
print(f"Conflicts Detected: {result.conflict_count}")
Core Invariants
| # | Invariant | Description |
|---|---|---|
| 1 | Append-only | Operation history is immutable. |
| 2 | Causal consistency | Hybrid Logical Clocks (HLC) ensure correct partial ordering and wall-clock correlation. |
| 3 | Deterministic | Replay results are identical across all replicas. |
| 4 | Field-Level Merge | "Smart" LWW resolution merges concurrent non-conflicting field updates. |
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your Sync System / App โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ Uses
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โ sqlite-sync-core โ
โ (Logging, Bundling, Clocks) โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ Persists to
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โ SQLite Database โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
License
AGPL-3.0 for Open Source. Contact shivaysinghrajput@proton.me for commercial licensing.
Built for developers who need a reliable sync foundation.
Project details
Release history Release notifications | RSS feed
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 sqlite_sync_core-0.5.3.tar.gz.
File metadata
- Download URL: sqlite_sync_core-0.5.3.tar.gz
- Upload date:
- Size: 93.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fb4799c250b9674c35bba65935a65eee6671b84c3992dd65e5815d347bdfce3
|
|
| MD5 |
b9e12fca321d4309b22e58802c0100ea
|
|
| BLAKE2b-256 |
2982f1d917b2cf42178f167b7f6609995031d899d209fa6ff3efca0727fda2de
|
File details
Details for the file sqlite_sync_core-0.5.3-py3-none-any.whl.
File metadata
- Download URL: sqlite_sync_core-0.5.3-py3-none-any.whl
- Upload date:
- Size: 106.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5cdeb139068407bd6747447f1a0394c3fa11fb3575ab59116f06a591f753b48
|
|
| MD5 |
443a9a315a7aa9846c269e99254534c3
|
|
| BLAKE2b-256 |
ff10afac6dfc03fba7ed03c2b8146188e1173f1e48778f2eb8416e80fd0bec11
|