Skip to content

litesql/ha-sync

Repository files navigation

ha-sync

SQLite extension to create local read replicas from HA database.

Installation

Download ha-sync extension from the releases page. Here's a great article that explains how to install the SQLite extension.

Compiling from source

  • Go 1.25+ and CGO_ENABLED=1 is required.
go build -ldflags="-s -w" -buildmode=c-shared -o ha-sync.so
  • Use .so extension for Linux, .dylib for MacOS and .dll for Windows

Basic usage

Loading the extension

sqlite3

# Load the extension
.load ./ha-sync

# check version (optional)
SELECT ha_info();

Create a virtual table to start replication

CREATE VIRTUAL TABLE temp.ha USING HA(servers='nats://localhost:4222', timeout=5000, logger='file:ha-sync.log');

-- Insert the subject name into the created virtual table to start replication
INSERT INTO temp.ha(subject, durable) VALUES('ha_replication.ha_db', 'my_instance');

Change Deliver Policy

DELETE FROM temp.ha WHERE durable = 'my_instance';

INSERT INTO temp.ha(subject, durable, policy) VALUES('ha_replication.ha_db', 'my_instance', 'by_start_sequence=42');

About

SQLite extension to sync HA database with local SQLite

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published