pgmicro
Skill by ara.so — Daily 2026 Skills collection.
pgmicro is an in-process reimplementation of PostgreSQL backed by a SQLite-compatible storage engine. It parses PostgreSQL SQL using the real PostgreSQL parser (libpg_query) and compiles it directly to SQLite VDBE bytecode, executed by Turso. The result is a fast, embeddable, single-file (or in-memory) database that speaks PostgreSQL — no server process required.
Key capabilities
- Full PostgreSQL SQL syntax (via the actual PG parser)
- SQLite-compatible
.dbfile format (readable by any SQLite tool) - JavaScript/TypeScript SDK (WASM-based, runs in Node.js and browsers)
- PostgreSQL wire protocol server mode (connect with
psql, ORMs, etc.) - Dialect switching: access the same database with PG or SQLite syntax
- PostgreSQL system catalog virtual tables (
pg_class,pg_attribute,pg_type, etc.)
Installation
CLI (Node.js)
JavaScript/TypeScript SDK
From source (Rust)
CLI usage
CLI meta-commands
JavaScript/TypeScript SDK
Basic usage
Parameterized queries
Transactions
Using with TypeScript types
PostgreSQL features supported
Server mode with psql / ORMs
Architecture overview
- The
.dboutput file is a standard SQLite database — open it with DB Browser for SQLite, thesqlite3CLI, or any SQLite library. - PostgreSQL system catalog tables (
pg_class,pg_attribute,pg_type,pg_namespace) are exposed as virtual tables sopsqlmeta-commands like\dtand\dwork correctly.
Common patterns
Per-request ephemeral databases (AI agents, sandboxes)
Inspecting the SQLite file directly
Schema introspection via pg catalog
Troubleshooting
SERIAL column not auto-incrementing
Ensure you are not explicitly inserting NULL into the id column — insert without the column name and pgmicro will auto-assign.
psql meta-commands (\dt, \d) show nothing
Make sure you created tables in the public schema (the default). The PostgreSQL catalog virtual tables are populated from actual schema metadata.
File database not persisting
Pass a real file path, not :memory:. Confirm the process has write permission to the target directory.
Wire protocol server refused by client The server supports a subset of the PostgreSQL wire protocol. Some advanced client features (SSL, SCRAM auth, extended query protocol edge cases) may not be implemented yet. Use simple query mode when possible.
Unsupported PostgreSQL syntax
pgmicro is experimental — not all PostgreSQL features are translated. Check the translator layer (parser_pg/) for what is currently mapped. Common gaps: stored procedures with complex PL/pgSQL, window functions, CTEs (may be partial), COPY command.
Build errors from source
Ensure you have a recent stable Rust toolchain (rustup update stable) and that libpg_query native dependencies (C compiler, cmake) are available on your system.
Resources
- GitHub: glommer/pgmicro
- Turso (upstream engine)
- libpg_query — the PostgreSQL parser extraction library
- pg_query Rust crate
- npm: pg-micro


