Mycelite is a SQLite extension that allows you to synchronize changes from one instance of SQLite to another.

Overview

Mycelite

What is Mycelite?

Mycelite is a SQLite extension that allows you to synchronize changes from one instance of SQLite to another. Currently, it only supports one-way synchronization, but eventually, it will support two-way synchronization.

Why would you want to synchronize multiple SQLite databases? Read on to learn.

A new type of application

There is a new type of application called local-first, which combines many of the best features from both local and client/server applications.

What does local-first offer?

With local-first applications, you get the speed and responsiveness of a local application, but at the same time, you get many of the desirable features from client/server systems.

What do local-first applications look like?

A good example of a local-first application is Actual Budget, an open-source personal finance application.

What makes Actual Budget different from its competitors?

First of all, it's very fast because all the application data is on the local device - in a SQLite database - but what's most interesting about this app is that it works on multiple devices. In other words, it has apps for iOS, Android, Windows, Mac and the Web and it allows you to make concurrent changes on multiple devices and synchronize those changes to all your devices.

Why aren't more developers creating local-first applications?

Actual Budget is a good example of a local-first application, but it wasn't very easy to build. The authors had to write a bunch of synchronization-related code, that implements and uses CRDTs, and this start-from-scratch approach just isn't practical for most situations. Building local-first applications today is too difficult, but we're going to change that.

Quickstart

Prerequisites

Install Rust. The version of Rust must be >= 1.65.

Install a recent version of SQLite. The default version of SQLite that comes preinstalled may not support extensions. For Mac users, Brew will install an appropriate build of SQLite. Note: you may need to modify your $PATH. Pay close attention to Brew's PATH instructions.

Building Mycelite

After cloning the repo, run the following to build Mycelite:

git clone [email protected]:mycelial/mycelite.git
cd mycelite
cargo build --release

This will create a shared library in ./target/release/libmycelite.dylib.

Command Line (CLI)

Replicator

Start the replicator service with the following terminal command:

cd mycelite/examples
cargo run -p sync-backend

SQLite Writer

In a new terminal, start a SQLite writer instance with the following command:

cd mycelite
MYCELIAL_WRITER=true sqlite3

After SQLite's CLI opens, load the extension and open the database with the following commands:

.load ./target/release/libmycelite
.open writer.db

SQLite Reader

In a new terminal, start a SQLite reader instance with the following command:

cd mycelite
MYCELIAL_WRITER=false sqlite3

After SQLite's CLI opens, load the extension and open the database with the following commands:

.load ./target/release/libmycelite
.open reader.db

Observing Synchronization

In the writer instance, create a table and then populate the table. For example:

create table test(int);
insert into test values (42);

Now in the reader instance, you will see the new table and you can query its values. For example:

.tables
select * from test; -- # returns 42

License

Apache 2.0

You might also like...
LIMITS is yet another fully open source, interoperable, decentralised real-time communication protocol!

LIMITS: Limit-IM does not have ITS LIMITS We are undergoing a major refactoring and technology stack adjustment to better accommodate clustered deploy

Another minimal Raft implementation in Rust.

raft-rs Not my first time implementing Raft. I wrote about another implementation in Go I did. But you don't learn a concept well until you've impleme

Yet another CRUD. This time in Rust.

crust ____ ____ _ ____ _____ / _\/ __\/ \ /\/ ___\/__ __\ | / | \/|| | ||| \ / \ | \__| /| \_/|\___ | | | \____/\_/\_\\___

Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules - port of vfsstat.c

Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules The vfs and vtab This is a port of the official ext/misc/vfsstat.c sqlite3 e

postgres-ical - a PostgreSQL extension that adds features related to parsing RFC-5545 « iCalendar » data from within a PostgreSQL database

postgres-ical - a PostgreSQL extension that adds features related to parsing RFC-5545 « iCalendar » data from within a PostgreSQL database

fast & easy CLI and vscode extension specialized to format MySQL INSERT queries.
fast & easy CLI and vscode extension specialized to format MySQL INSERT queries.

insertfmt fast & easy CLI specialized to format MySQL INSERT queries. format queries so that they look like a table. NOTE: If you wanna use the VSCode

🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.

SQLx 🧰 The Rust SQL Toolkit Install | Usage | Docs Built with ❤️ by The LaunchBadge team SQLx is an async, pure Rust† SQL crate featuring compile-tim

Ergonomic bindings to SQLite for Rust

Rusqlite Rusqlite is an ergonomic wrapper for using SQLite from Rust. It attempts to expose an interface similar to rust-postgres. use rusqlite::{para

SQLite clone from scratch in Rust
SQLite clone from scratch in Rust

Rust-SQLite (SQLRite) Rust-SQLite, aka SQLRite , is a simple embedded database modeled off SQLite, but developed with Rust. The goal is get a better u

Comments
  • Add a primitive sync-backend example

    Add a primitive sync-backend example

    In order to let developers play the sqlite extension, I am adding this example which does not implement any sort of protocol nor safety, and supports only a single database at a time.

    How to run it

    $ cd examples && cargo run -p sync-backend
    
    <the build process omitted>
    
        Finished dev [unoptimized + debuginfo] target(s) in 4.97s
         Running `target/debug/sync-backend`
    2022-12-05T16:36:07.466895Z DEBUG sync_backend: listening on 0.0.0.0:8080
    
    
    opened by artps 3
  • Adds journal bootstrapping for pre-existing database

    Adds journal bootstrapping for pre-existing database

    Adds serde_sqlite crate and add page_parser crate. Data format was moved from journal to serde_sqlite. Page parser added and is able to parse sqlite database header.

    opened by dmzmk 0
A multi-instance, Discord/Spacebar API-compatible chat client

Polyphony A multi-instance, Discord/Spacebar API-compatible chat client, written in Rust and Svelte (TypeScript) using Tauri. Explore the docs » Repor

null 6 Apr 3, 2023
Provides a Rust-based SQLite extension for using Hypercore as the VFS for your databases.

SQLite and Hypercore A Rust library providing SQLite with an virtual file system to enable Hypercore as a means of storage. Contributing The primary r

Jacky Alciné 14 Dec 5, 2022
A SQLite extension for quickly generating random numbers, booleans, characters, and blobs

sqlite-fastrandom A SQLite extension for quickly generating random numbers, booleans, characters, and blobs. Not cryptographically secure. Based on sq

Alex Garcia 11 Feb 2, 2023
SQLite extension for working with operating system's clipboard (copy/paste functions)

SQLite extension for working with operating system's clipboard This extension adds the following functions to SQLite: Copy Paste Long name CLIPBOARD_C

Sergey Khabibullin 4 Jun 12, 2023
SQLite Extension adding various hashing functions like MD5, SHA1, SHA256, SHA512, etc.

sqlite-hashes Use this crate to add various hash functions to SQLite, including MD5, SHA1, SHA256, and SHA512. This crate uses rusqlite to add user-de

Yuri Astrakhan 3 Jul 28, 2023
Grsql is a great tool to allow you set up your remote sqlite database as service and CRUD(create/read/update/delete) it using gRPC.

Grsql is a great tool to allow you set up your remote sqlite database as service and CRUD (create/ read/ update/ delete) it using gRPC. Why Create Thi

Bruce Yuan 33 Dec 16, 2022
Automatically publish MongoDB changes to Redis for Meteor.

changestream-to-redis Warning The project is currently in its alpha phase. There are no production loads using it yet nor any large-scale tests were c

Radosław Miernik 8 Jul 29, 2023
This crate allows you to send cypher queries to the REST endpoint of a neo4j database

rusted_cypher Rust crate for accessing the cypher endpoint of a neo4j server This crate allows you to send cypher queries to the REST endpoint of a ne

Livio Ribeiro 68 Dec 1, 2022
rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

Foretag 3 Mar 24, 2022
Yet Another Kev-Value DataBase

Yet Another Kev-Value DataBase Extremely simple (simplest possible?) single-file BTree-based key-value database. Build for fun and learning: goal is t

Sergey Melnychuk 18 May 23, 2022