pgmicro  by glommer

PostgreSQL SQL for AI agent databases, embeddable and file-based

Created 2 weeks ago

New!

851 stars

Top 41.8% on SourcePulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

An in-process reimplementation of PostgreSQL, pgmicro offers an embeddable, single-file database solution for developers who prefer PostgreSQL's feature set but need SQLite's deployment simplicity, particularly for ephemeral use cases like AI agents. It achieves this by compiling PostgreSQL SQL directly to a SQLite-compatible storage engine, providing a fast alternative without the overhead of managing a separate database server.

How It Works

pgmicro utilizes libpg_query for 100% PostgreSQL SQL parsing fidelity, translating the resulting parse tree into Turso's internal Abstract Syntax Tree (AST). This AST is then compiled into VDBE bytecode by the Turso engine, a Rust reimplementation of SQLite, which executes against standard SQLite B-tree storage. This architecture bypasses the complexities of embedding PostgreSQL directly or fighting its traditional server model, offering PostgreSQL syntax compatibility within an embeddable, file-based framework.

Quick Start & Requirements

Installation is straightforward via npm: npm install -g pg-micro for the command-line interface (CLI) or npm install pg-micro for the JavaScript/TypeScript SDK. The CLI supports running databases in-memory (pgmicro) or backed by a file (pgmicro myapp.db). The SDK provides programmatic access. Node.js and npm are the primary prerequisites.

Highlighted Details

  • Achieves 100% PostgreSQL syntax parsing fidelity using the libpg_query library.
  • Underlying data storage is a standard SQLite .db file, inspectable with any SQLite tool.
  • Includes a PostgreSQL wire protocol server, enabling connections from standard PostgreSQL clients like psql.
  • Supports dynamic dialect switching, allowing simultaneous access via PostgreSQL and SQLite syntax on a single database.
  • Exposes PostgreSQL catalog tables (e.g., pg_class, pg_attribute) for schema metadata compatibility.

Maintenance & Community

This project is explicitly labeled "heavily experimental," with no guarantees provided regarding stability, compatibility, or completeness. While not officially affiliated with Turso, the author is the founder of Turso. Contributions are welcome, with a guideline to build upon Turso's core and minimize changes to its active development.

Licensing & Compatibility

pgmicro is licensed under the permissive MIT license, identical to Turso. This license permits commercial use and integration within closed-source applications without significant restrictions.

Limitations & Caveats

The project's experimental nature means users should anticipate potential instability, incomplete feature support, and breaking changes. The active development of the underlying Turso core may also lead to frequent merge conflicts for contributors.

Health Check
Last Commit

2 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
2
Issues (30d)
1
Star History
854 stars in the last 16 days

Explore Similar Projects

Feedback? Help us improve.