zknill/sqledge
zknill/sqledge has 1,041 GitHub stars and 20 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-09 11:44 UTC. Last push 2024-06-17.
Replicate postgres to SQLite on the edge
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalSQLedge
[State: alpha]
SQLedge uses Postgres logical replication to stream the changes in a source Postgres database to a SQLite database that can run on the edge. SQLedge serves reads from its local SQLite database, and forwards writes to the upstream Postgres server that it's replicating from.
This lets you run your apps on the edge, and have local, fast, and eventually consistent access to your data.

SQL generation
The pkg/sqlgen package has an SQL generator in it, which will generate the SQLite insert, update, delete statements based on the logical replication messages received.
SQL parsing
When the database is started, we look at which tables already exist in the sqlite copy, and make sure new tables are created automatically on the fly.
Postgres wire proxy
SQLedge contains a Postgres wire proxy, default on localhost:5433. This proxy uses the local SQlite database for reads, and forwards writes to the upstream Postgres server.
Compatibility
When running, the SQL statements interact with two databases; Postgres (for writes) and SQLite (for reads).
The Postgres wire proxy (which forwards reads to SQLite) doesn't currently translate any of the SQL statements from the Postgres query format/functions to the SQLite format/functions.
Read queries issued against the Postgres wire proxy need to be compatible with SQLite directly.
This is fine for simple SELECT queries, but you will have trouble with Postgres-specific query functions or syntax.
Copy on startup
SQLEdge maintains a table called postgres_pos, this tracks the LSN (log sequence number) of the received logical replication messages so it can pick up processing where it left
off.
If no LSN is found, SQLedge will start a postgres COPY of all tables in the public schema. Creating the appropriate SQLite tables, and inserting data.
When the replication slot is first created, it exports a transaction snapshot. This snapshot is used for the initial copy. This means that the COPY command will read the data from
the transaction at the moment the replication slot was created.
Trying it out
Create a database
create database myappdatabase;Create a user -- must be a super user because we create a publication on all tables
create user sqledger with login superuser password 'secret';Run the example
SQLEDGE_UPSTREAM_USER=sqledger SQLEDGE_UPSTREAM_PASSWORD=secret SQLEDGE_UPSTREAM_NAME=myappdatabase go run ./cmd/sqledge/main.goConnect to the postgres wire proxy
psql -h localhost -p 5433 $ CREATE TABLE my_table (id serial not null primary key, names text); $ INSERT INTO my_table (names) VALUES ('Jane'), ('John'); $ SELECT * FROM my_table;The read will be served from the local database
Connect to the local sqlite db
sqlite3 ./sqledge.db .schema
Config
All config is read from environment variables. The full list is available in the struct tags on the fields in pkg/config/config.go
Explore related projects
Asabeneh/30-Days-Of-Python
The 30 Days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than 100 days. Follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,423 starsgrafana/grafana
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
77,790 starsredis/redis
For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.
77,309 starsapache/superset
Apache Superset is a Data Visualization and Data Exploration Platform
75,455 stars