pg-micro is an experimental, in-process reimplementation of PostgreSQL, currently at version 0.0.5. It is built as an experimental fork of Turso, which is a full, from-scratch rewrite of SQLite in Rust. Unlike other approaches that try to compile PostgreSQL to WebAssembly or translate PostgreSQL syntax to SQLite, pg-micro directly parses the PostgreSQL language using `libpg_query` (the same parser PostgreSQL itself uses) and compiles it to SQLite bytecode for execution on Turso's engine. This approach aims to provide a fast, embeddable, single-file database that natively understands PostgreSQL syntax, targeting ephemeral, low-touch, short-lived, and small database use cases. Its key differentiators include 100% PostgreSQL syntax fidelity, direct compilation to SQLite bytecode, and a standard SQLite-compatible storage format, allowing for dual access via PostgreSQL and SQLite syntax. Release cadence is currently irregular due to its experimental nature and close ties to Turso's development cycle.
npm install pg-microVerified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to an in-memory pg-micro database, creating a table, inserting data with prepared statements, and querying results.
Refer to the latest GitHub repository and any available changelogs for the most up-to-date API and usage patterns before upgrading. Pin exact versions in production.
Thoroughly test complex PostgreSQL queries and features in `pg-micro` to confirm compatibility and expected behavior. Check the project's documentation or issue tracker for known limitations.
Monitor both `pg-micro` and `Turso` repositories for significant updates, architectural changes, or potential shifts in project direction. Consider the long-term viability in relation to Turso's status.
Ensure all database operations complete before calling `db.close()`. Use `await` for asynchronous operations. Re-establish a new connection if further operations are needed after closing.
Simplify the SQL query, or consult the `pg-micro` GitHub repository and issues for known limitations regarding specific PostgreSQL features or syntax. Test queries incrementally to identify the problematic part.
Ensure `await connect(...)` completes successfully and that the returned `Database` instance is valid before attempting to call its methods. Add error handling around the `connect` call.
No dependency data recorded yet.