cr-sqlite

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite

What is cr-sqlite?

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite

Overview of cr-sqlite

What it is

cr-sqlite is a run-time loadable extension for SQLite and libSQL. It allows merging different SQLite databases that have taken independent writes, adding multi-master replication and partition tolerance via conflict free replicated data types (CRDTs) and/or causally ordered event logs.

Key features

  • Upgrades existing tables to conflict free replicated relations (CRRs) using the crsql_as_crr function
  • Provides a crsql_changes virtual table to fetch and apply changesets between databases
  • Supports altering CRR table definitions with crsql_begin_alter and crsql_commit_alter
  • Pre-built binaries are available in the releases section for loading into SQLite from any language with SQLite bindings
  • A WASM build is available for browser use

Use cases

  • Syncing data between devices
  • Implementing realtime collaboration
  • Offline editing
  • Being resilient to network conditions
  • Enabling instantaneous interactions

Getting started

Load the extension, create tables, upgrade them to CRRs, insert data, and query or merge changes. Example from the README:

.load crsqlite
create table foo (a primary key not null, b);
select crsql_as_crr('foo');
insert into foo (a,b) values (1,2);
select "table", "pk", "cid", "val", "col_version", "db_version", "site_id", "cl", "seq" from crsql_changes;
-- Merge changes from a peer
insert into crsql_changes ("table", "pk", "cid", "val", "col_version", "db_version", "site_id", "cl", "seq") values (...);

For full documentation, see the repository README.

License and pricing

License: MIT. The project is open source with no stated pricing.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/vlcn-iocr-sqlite.svg)](https://yunodb.com/tools/vlcn-iocr-sqlite?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/vlcn-iocr-sqlite?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/vlcn-iocr-sqlite.svg" alt="Featured on YunoDB" height="20"></a>