{"id":33178105,"url":"https://github.com/litesql/ha","last_synced_at":"2026-04-16T01:00:36.401Z","repository":{"id":315810992,"uuid":"1060804358","full_name":"litesql/ha","owner":"litesql","description":"Highly available leader/leaderless SQLite cluster powered by embedded NATS JetStream server","archived":false,"fork":false,"pushed_at":"2026-03-28T19:49:24.000Z","size":3121,"stargazers_count":73,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-13T00:39:14.837Z","etag":null,"topics":["go","golang","high-availability","nats","pg-wire","sqlite"],"latest_commit_sha":null,"homepage":"https://litesql.github.io/ha/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/litesql.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"walterwanderley","liberapay":"walterwanderley"}},"created_at":"2025-09-20T16:18:19.000Z","updated_at":"2026-03-28T19:46:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca9ccb87-44b9-4e65-b2bd-0b5be3ab996e","html_url":"https://github.com/litesql/ha","commit_stats":null,"previous_names":["litesql/ha"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/litesql/ha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesql%2Fha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesql%2Fha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesql%2Fha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesql%2Fha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litesql","download_url":"https://codeload.github.com/litesql/ha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesql%2Fha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31866357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","high-availability","nats","pg-wire","sqlite"],"created_at":"2025-11-16T03:00:31.890Z","updated_at":"2026-04-16T01:00:36.392Z","avatar_url":"https://github.com/litesql.png","language":"Go","readme":"# ha\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![LiberaPay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/walterwanderley/donate)\n[![receives](https://img.shields.io/liberapay/receives/walterwanderley.svg?logo=liberapay)](https://liberapay.com/walterwanderley/donate)\n[![patrons](https://img.shields.io/liberapay/patrons/walterwanderley.svg?logo=liberapay)](https://liberapay.com/walterwanderley/donate)\n\n![](ha.png)\n\n\n## Highly available SQLite cluster \n\nPowered by an embedded NATS JetStream server.\n\n## Features\n\n- 🔌 Connect using HTTP API, [gRPC API](https://buf.build/litesql/sqlite-ha/sdks/main:grpc), [database/sql go driver](https://github.com/litesql/go-ha), [JDBC driver](https://github.com/litesql/jdbc-ha), MySQL or PostgreSQL Wire Protocol\n- 🔁 Replicate data using embedded or external NATS server\n- 📝 Create live local **read/write** replicas with [go-ha database/sql driver](https://github.com/litesql/go-ha)\n- 📚 Create live local read replicas with [ha-sync SQLite extension](https://github.com/litesql/ha-sync)\n- 🔄 Supports Change Data Capture (CDC)\n- ⚙️ Configure a leader-based or leaderless cluster (with custom strategies for resolving replication data conflicts)\n- 📚 Execute cross-shard queries using SQL hint /*+ db=DSN */ (where DSN is a regexp to DataSource name)\n- 📖 Full documentation: [https://litesql.github.io/ha/](https://litesql.github.io/ha/)\n\n## 🚀 Getting Started\n\nDownload and install the [latest release](https://github.com/litesql/ha/releases/latest)\n\n### 1. Start the first **ha** instance\n\n```sh\nmkdir db1\nha -n node1 --pg-port 5432 --mysql-port 3306 \"file:db1/mydatabase.db\"\n```\n\nThis command launches:\n\n- An embedded NATS server on port 4222\n- A MySQL Wire Protocol compatible server on port 3306\n- A PostgreSQL Wire Protocol compatible server on port 5432\n- An HTTP API server on port 8080\n\n### 2. Start a second **ha** instance\n\n```sh\nmkdir db2\nha -n node2 --nats-port 0 -p 8081 --pg-port 5433 --mysql-port 3307 --replication-url nats://localhost:4222 \"file:db2/mydatabase.db\"\n```\n\nThis command starts:\n\n- A PostgreSQL Wire Protocol server on port 5433\n- A MySQL Wire Protocol server on port 3307\n- An HTTP API server on port 8081.\n\nIt connects to the previously launched embedded NATS server for replication.\n\n### 3. Connect using a client\n\nSpecial HA Client commands:\n\n|Command|Description|\n|-------|-----------|\n|SHOW DATABASES;|List all databases|\n|CREATE DATABASE dsn;|Create a new database|\n|DROP DATABASE id;|Drop a database|\n|SET DATABASE TO id;|Send commands to a specific database|\n|UNSET DATABASE;|Use default database|\n|HISTORY n;|Show the last n transactions (n can be a number or time duration like '5m')|\n|UNDO n;|Undo the last n transactions (n can be a number or time duration like '5m')|\n|EXIT;|Quit client (ctrl+d)|\n\n\n#### 3.1 HA Client\n\n```sh\nha -r http://localhost:8080\n```\n\n#### 3.2. PostgreSQL Client\n\n```sh\nPGPASSWORD=ha psql -h localhost -U ha\n```\n\n#### 3.3 MySQL Client\n\n```sh\nmysql -h localhost --port 3306 -u ha\n```\n\nCreate and populate a table:\n\n```sql\nCREATE TABLE users(ID INTEGER PRIMARY KEY, name TEXT);\nINSERT INTO users(name) VALUES('HA user');\n```\n\n### 4. Verify replication on the second instance\n\n```sh\nha -r http://localhost:8081\n```\n\nUsing postgresql client:\n\n```sh\nPGPASSWORD=ha psql -h localhost -U ha -p 5433\n```\n\n```sql\nSELECT * FROM users;\n ID |  name   \n----+---------\n 1  | HA user\n\n```\n\nUsing a mysql client:\n\n```sh\nmysql -h localhost --port 3307 -u ha\n\nMySQL [(none)]\u003e show databases;\n+---------------+\n| Database      |\n+---------------+\n| mydatabase.db |\n+---------------+\n1 row in set (0,000 sec)\n\nMySQL [(none)]\u003e use mydatabase.db\n\nMySQL [mydatabase.db]\u003e select * from users;\n+----+---------+\n| ID | name    |\n+----+---------+\n|  1 | HA user |\n+----+---------+\n1 row in set (0,000 sec)\n```\n\n### 5. Please refer to the complete documentation for the HTTP API\n\n[HTTP API](https://litesql.github.io/ha/#5)\n\n## 🛠️ License \u0026 Contributions\n\nThis project is open-source. Contributions, issues, and feature requests are welcome via [GitHub](https://github.com/litesql/ha).","funding_links":["https://github.com/sponsors/walterwanderley","https://liberapay.com/walterwanderley","https://liberapay.com/walterwanderley/donate"],"categories":["Built on top of NATS and JetStream","Misc"],"sub_categories":["Community Clients","Desktop"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitesql%2Fha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitesql%2Fha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitesql%2Fha/lists"}