Skip to main content

Universal SQLite Synchronization Core - A dependency-grade, local-first, offline-first SQLite synchronization primitive

Project description

sqlite-sync-core

Python 3.11+ License: AGPL-3.0 PyPI Status: Production Grade

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 app.db --name Device-A --table 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.

# On Device A
sqlite-sync start app.db --name Device-A --table tasks --port 8000

# On Device B (auto-discovers Device A)
sqlite-sync start app.db --name Device-B --table tasks --port 8001

๐Ÿ—๏ธ 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 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.

CLI Commands

Command Description
start Start full sync node with P2P discovery
init Initialize database for sync
serve Start HTTP sync server (simple mode)
sync Run sync with a specific peer
status Show sync status and conflicts
resolve Resolve conflicts interactively
migrate Manage schema migrations
peers Discover and manage peers
snapshot Create database snapshot

Start Command Options

sqlite-sync start <db_path> [OPTIONS]

Options:
  --name, -n        Device name for network discovery
  --table, -t       Tables to enable sync for (can repeat)
  --port, -p        Port to bind to (default: 8000)
  --interval, -i    Sync interval in seconds (default: 30)
  --auto-discover   Enable P2P discovery (default: enabled)
  --daemon, -d      Run as background daemon

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     Your Sync System / App      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ”‚ Uses
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚       sqlite-sync-core          โ”‚
โ”‚  (Logging, Bundling, Clocks)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ”‚ Persists to
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         SQLite Database         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

License

AGPL-3.0 for Open Source.
Commercial License available for enterprise use.

Contact shivaysinghrajput@proton.me for commercial licensing.


Built for developers who need a reliable sync foundation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlite_sync_core-0.7.0.tar.gz (103.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlite_sync_core-0.7.0-py3-none-any.whl (115.0 kB view details)

Uploaded Python 3

File details

Details for the file sqlite_sync_core-0.7.0.tar.gz.

File metadata

  • Download URL: sqlite_sync_core-0.7.0.tar.gz
  • Upload date:
  • Size: 103.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for sqlite_sync_core-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f19cea4c56f4a96ebc56fcfef3ad9e434f15c372ed51922128cbdf1a0c92a86c
MD5 a24b0678eb1450973d2faf1e9eca8dac
BLAKE2b-256 75b12197d67c59650897d74351bff60fda4a373f2b93442f7c74b1f5a40fb61f

See more details on using hashes here.

File details

Details for the file sqlite_sync_core-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlite_sync_core-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 879eeaea82ee808cae0d0d96c69cf743ae85ff081962fdf285046199ee9d9fe1
MD5 0d35cc7301e1b8752811bfe03b3a8de2
BLAKE2b-256 f51dfe091fc9165ce91453bff5a9f2aa5d1e0e03555adaa987767aac5cfaf445

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page