PostgreSQL inside your application.¶
PostgreSQL 19 · embedded runtime
Run PostgreSQL in your application process—with transactions, WAL, crash recovery, and bundled extensions, but no database server to install or supervise.
- Linux x86-64
- glibc 2.17+
- PostGamma · Apache-2.0
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);
}
no SQL socket
Python and C
Choose the interface that fits.
Both SDKs bundle the same PostgreSQL kernel and version-matched resources. Neither requires an installed PostgreSQL server.
Install once.
Import normally.
The wheel bundles the Python API, PostgreSQL kernel, and version-matched resources for each supported CPython ABI. The installation command below applies after publication; see downloads for current availability.
python -m pip install "postgamma==0.1.0a1"Link PostgreSQL
into native software.
Link against libpostgamma.a; its stable public ABI keeps PostgreSQL implementation types private.
pkg-config --static --libs postgammaThe PostgreSQL core, reframed
Keep the database semantics.
Lose the service boundary.
PostGamma changes PostgreSQL’s deployment model while preserving its database behavior. Your application owns startup and shutdown; PostgreSQL still owns parsing, planning, catalogs, transactions, WAL, and recovery.
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.
Built for local software
Put PostgreSQL where a separate service does not fit.
PostGamma is not a universal replacement for a PostgreSQL server. Each cluster directory can be owned by only one live OS process at a time.
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.
Give your application
a path and ordinary SQL.
The quickstart shows what PostGamma creates, where the cluster lives, and how to reopen it safely.