PostgreSQL in your app, agent, and browser¶
PostgreSQL 19 · native + browser
Give your apps and AI agents PostgreSQL. Embed it with Python or C, run it as a threaded server, or use it in your browser.
- Embedded · Server · Browser
- Server source build · Browser preview
- PostGamma · Apache-2.0
Preparing your browser
Created locally. Review before sharing.
Edit the SQL, then start the demo.
Sample data stays in memory for this visit.
import postgamma
with postgamma.connect("agent.pgm",
autocommit=True) as db:
db.execute("create table notes "
"(id bigint, body text)")
db.execute("insert into notes values ($1, $2)",
[1, "local memory"])
rows = db.execute("select * from notes").fetchall()
# [(1, 'local memory')]
#include <postgamma/postgamma.h>
int main(void) {
pgm_instance_options opts = PGM_INSTANCE_OPTIONS_INIT;
pgm_connection_options session = PGM_CONNECTION_OPTIONS_INIT;
pgm_instance *engine = NULL;
pgm_connection *db = NULL;
pgm_result *rows = NULL;
pgm_error *error = NULL;
opts.path = "agent.pgm";
opts.create = 1;
pgm_instance_open(&opts, &engine, &error);
pgm_connection_open(engine, &session, &db, &error);
pgm_execute(db, "select 'local memory'", NULL, 0,
PGM_FORMAT_TEXT, -1, &rows, &error);
pgm_result_free(rows);
pgm_connection_close(db, -1, &error);
pgm_instance_close(engine, PGM_SHUTDOWN_SMART, -1, &error);
}
Embedded, Server and Browser
Choose how you run PostgreSQL.
Own the database inside your app, connect to a threaded server, or run SQL locally in the browser.
PostgreSQL inside
your application.
Import the Python package or link libpostgamma.a. Your app owns the database lifecycle, with no separate server to manage. Install the current alpha from PyPI, or see downloads for the wheels and static C SDK.
postgamma.connect("agent.pgm")A familiar server.
A threaded engine.
Run PostgreSQL roles as threads in a standalone server. Connect with psql or a PostgreSQL driver. Build from source today; a separate server binary package is not yet available.
make threaded-postgresql-buildReal PostgreSQL.
Right in your browser.
Run SQL, JSONB, transactions and pgvector locally. Start in memory, or explicitly enable OPFS storage. The browser package is currently built from source.
const db = await Database.open();The PostgreSQL core, reframed
Keep the database semantics.
Choose the runtime boundary.
The threaded kernel powers each mode. PostgreSQL owns parsing, planning, catalogs, transactions, WAL, and recovery; you choose an embedded API, a server connection, or a browser Worker.
Use the SQL and semantics you already know.
Preserved behavior includes PostgreSQL syntax and types, SQLSTATE diagnostics, prepared statements, COPY, notices, notifications, and logical dump and restore.
select id, body from notes;One process.
One lifecycle.
No database server to install, configure, or supervise.
Open, connect, query, and close explicitly.
- 01Openinitialize or recover
- 02Connectcreate logical sessions
- 03QuerySQL, COPY, vectors
- 04Closeclean shutdown
Vector search,
inside the same process.
pgvector 0.8.6 is bundled and validated with the embedded kernel. Only reviewed extensions are linked into each build.
Embedded and browser use cases
Put PostgreSQL where a separate service does not fit.
Use embedded mode when the app owns its database. For independent clients, explore the threaded server source build. Each native cluster directory still has one owner process.
Read the selection guideAgents and developer tools
Structured state, task data, and vector search beside the application.
Desktop and edge software
A PostgreSQL data layer that ships with the application itself.
Tests and reproducible jobs
Isolated PostgreSQL clusters through an API, without provisioning a server.
Start small. Keep PostgreSQL.
Choose your runtime.
Run your first query.
Start with the project overview, then follow the Python, C, server, or browser quickstart for your application.