You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-20Lines changed: 42 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,25 @@
1
1
# sqlite2pg
2
2
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
+
<divalign="center">
4
+
5
+
**Zero-config SQLite to PostgreSQL & Supabase Exporter and Migrator.**
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.
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`**|
0 commit comments