Skip to content

Commit 5ac340c

Browse files
author
Pushkar
committed
docs: proper badge links, clean comparison matrix and formatting
1 parent 83940bd commit 5ac340c

2 files changed

Lines changed: 43 additions & 21 deletions

File tree

‎README.md‎

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
# sqlite2pg
22

3-
A zero-config CLI and Node.js library to convert SQLite databases into clean, PostgreSQL-compatible SQL migrations for Supabase, Neon, and standard PostgreSQL instances.
3+
<div align="center">
4+
5+
**Zero-config SQLite to PostgreSQL & Supabase Exporter and Migrator.**
6+
7+
[![CI](https://github.com/pushkarreddyy/sqlite2pg/actions/workflows/ci.yml/badge.svg)](https://github.com/pushkarreddyy/sqlite2pg/actions)
8+
[![Node Version](https://img.shields.io/badge/node-%3E%3D18.0.0-339933.svg)](https://nodejs.org)
9+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6.svg)](https://www.typescriptlang.org)
10+
[![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)](tests)
11+
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
12+
13+
Migrates local SQLite, LibSQL, and Turso databases directly to Supabase, Neon, AWS RDS, or standard PostgreSQL instances with strict types, transaction wrapping, and sequence synchronization.
14+
15+
```
16+
┌─────────────────┐ sqlite2pg ┌──────────────────────────────┐
17+
│ Local SQLite │ ────────────────────► │ PostgreSQL / Supabase │
18+
│ (app.db) │ Fast DDL & Data │ (Strict Types, RLS, setval) │
19+
└─────────────────┘ └──────────────────────────────┘
20+
```
21+
22+
</div>
423

524
---
625

@@ -12,7 +31,7 @@ A zero-config CLI and Node.js library to convert SQLite databases into clean, Po
1231
npx sqlite2pg ./app.db -o migration.sql
1332
```
1433

15-
For Supabase targets (enables Row Level Security and UUID extensions):
34+
For Supabase targets (automatically configures Row Level Security and UUID extensions):
1635

1736
```bash
1837
npx sqlite2pg ./app.db -o migration.sql --target supabase
@@ -36,24 +55,27 @@ npx sqlite2pg ./app.db --conn "postgres://postgres:password@db.supabase.co:5432/
3655

3756
---
3857

39-
## Why sqlite2pg?
58+
## Comparison
4059

41-
Dumping SQLite with standard `sqlite3 .dump` or migrating via `pgloader` creates common failure points on PostgreSQL:
42-
43-
- **AUTOINCREMENT Syntax**: SQLite's `INTEGER PRIMARY KEY AUTOINCREMENT` is invalid in PostgreSQL. `sqlite2pg` maps this to `BIGSERIAL PRIMARY KEY` or standard `GENERATED BY DEFAULT AS IDENTITY`.
44-
- **Foreign Key Load Order**: Standard SQL dumps insert rows in table order, failing when child tables appear before parents. `sqlite2pg` creates tables, loads all data in transactions, and adds foreign key constraints at the end.
45-
- **Sequence Desync**: Inserting explicit primary keys into PostgreSQL leaves serial sequences out of sync, causing subsequent `INSERT` statements from your application to throw duplicate key errors. `sqlite2pg` automatically includes `SELECT setval(...)` resets for all sequences.
46-
- **Boolean Normalization**: SQLite represents booleans as integers (`0`/`1`) or strings (`'0'`/`'1'`). `sqlite2pg` casts them to strict PostgreSQL `TRUE`/`FALSE` literals.
47-
- **Timestamp Parsing**: SQLite `strftime` formats (`YYYY-MM-DD HH:MM:SS`), ISO strings, and unix epochs are converted to valid PostgreSQL `TIMESTAMPTZ` values.
48-
- **Bytea and Hex Blobs**: Binary BLOB fields are encoded into PostgreSQL `'\x...'::bytea` hex format.
49-
- **Reserved Words**: Table and column identifiers matching SQL keywords (`user`, `order`, `group`, `table`) are properly quoted.
50-
- **Zero Native Toolchain**: Built on Node's native SQLite engine with no Python, C++, or Common Lisp dependencies. Runs directly via `npx` across macOS, Linux, and Windows.
60+
| Feature / Issue | Standard `sqlite3 .dump` | `pgloader` | `sqlite2pg` |
61+
| :--- | :---: | :---: | :---: |
62+
| **`AUTOINCREMENT` Syntax** | Fails in Postgres | Requires custom config | **Maps to `BIGSERIAL` / `IDENTITY`** |
63+
| **Foreign Key Load Order** | Fails on insert order | Complex setup | **Defers constraints after data load** |
64+
| **Sequence Synchronization** | Fails on next app insert | Inconsistent | **Auto-generates `setval` for all tables** |
65+
| **Boolean Values (`0`/`1`)** | Type mismatch error | Partial | **Normalizes to strict `TRUE`/`FALSE`** |
66+
| **Timestamp & Epoch Parsing** | Format errors | Inconsistent | **Normalizes to valid `TIMESTAMPTZ`** |
67+
| **Binary BLOBs** | Fails on `X'...'` syntax | Memory heavy | **Encodes as `'\x...'::bytea`** |
68+
| **Reserved SQL Keywords** | Fails on `user`, `order`, etc. | Needs mapping rules | **ANSI double-quotes all identifiers** |
69+
| **Supabase RLS & Extensions** | Not supported | Not supported | **Built-in with `--target supabase`** |
70+
| **Runtime & Dependencies** | Shell-dependent | Common Lisp / sbcl | **Zero-dependency Node.js native engine** |
5171

5272
---
5373

5474
## Type Conversions
5575

56-
| SQLite Type / Affinity | PostgreSQL Type | Handling Notes |
76+
`sqlite2pg` inspects SQLite table declarations and sampled data to construct strict PostgreSQL schemas:
77+
78+
| SQLite Declaration | PostgreSQL Type | Handling Notes |
5779
| :--- | :--- | :--- |
5880
| `INTEGER PRIMARY KEY` (rowid) | `BIGSERIAL PRIMARY KEY` | Uses `BIGINT GENERATED ... AS IDENTITY` when `--identity` is set |
5981
| `INTEGER`, `INT`, `INT4` | `INTEGER` | Standard 32-bit integer |
@@ -100,9 +122,9 @@ Options:
100122

101123
---
102124

103-
## Programmatic Usage
125+
## Programmatic API
104126

105-
You can use `sqlite2pg` directly inside your Node.js or TypeScript application:
127+
`sqlite2pg` can be used directly in TypeScript or Node.js scripts:
106128

107129
```typescript
108130
import { convert, introspect } from 'sqlite2pg';
@@ -118,12 +140,12 @@ const { sql, stats } = convert('./app.db', {
118140
batchSize: 1000,
119141
});
120142

121-
console.log(`Generated migration in ${stats.durationMs}ms`);
143+
console.log(`Exported ${stats.tableCount} tables and ${stats.rowCount} rows in ${stats.durationMs}ms`);
122144
```
123145

124146
---
125147

126-
## Common Use Cases
148+
## Common Recipes
127149

128150
### Inspect schema without exporting
129151

@@ -143,7 +165,7 @@ npx sqlite2pg ./app.db --include users,orders,products -o subset.sql
143165
npx sqlite2pg ./app.db --schema-only -o schema.sql
144166
```
145167

146-
### SQL standard identity columns
168+
### Use SQL-standard identity columns
147169

148170
```bash
149171
npx sqlite2pg ./app.db --identity -o migration.sql
@@ -164,7 +186,7 @@ npm install
164186
# Build TypeScript
165187
npm run build
166188

167-
# Run unit and integration tests
189+
# Run test suite
168190
npm test
169191
```
170192

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"build": "tsc",
1313
"prepublishOnly": "npm run build",
14-
"test": "node --import tsx/esm tests/converter.test.ts",
14+
"test": "tsx --test tests/*.test.ts",
1515
"start": "tsx src/cli.ts"
1616
},
1717
"keywords": [

0 commit comments

Comments
 (0)