Skip to main content

pgmem for Python

A real PostgreSQL 18 that runs entirely in memory, packaged as a single binary and driven from Python. Prepare the schema once, then give every test its own fork of that state in about 20 ms.

import pgmem, psycopg

with pgmem.start(database="app") as pg:
    with psycopg.connect(pg.template.dsn) as conn:
        conn.execute(open("schema.sql").read())
    snap = pg.template.snapshot()
    with snap.fork() as fork:            # private copy of the prepared database
        psycopg.connect(fork.dsn) ...

pytest

The wheel registers a plugin. Override pgmem_snapshot to run migrations, then use pgmem_dsn (or pgmem_fork) in tests:

# conftest.py
@pytest.fixture(scope="session")
def pgmem_snapshot(pgmem_server):
    run_migrations(pgmem_server.dsn)
    return pgmem_server.snapshot()

# test_orders.py
def test_orders(pgmem_dsn):
    with psycopg.connect(pgmem_dsn) as conn: ...

pgmem_class_dsn shares one fork across a test class for read-only tests. pgmem_options returns the keyword arguments passed to pgmem.start.

Any driver works (psycopg, asyncpg, pg8000, SQLAlchemy): the wrapper only hands out DSNs. The server is one PostgreSQL session per fork; pooled connections are serialized at transaction boundaries.

Binary

Platform wheels bundle the pgmem binary. PGMEM_BINARY overrides the lookup for platforms without a wheel or for local builds (go build ./cmd/pgmem).

Release files for pgmem 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pgmem 0.1.4
File
pgmem-0.1.4-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
pgmem-0.1.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pgmem-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux musl 1.1+ x86-64, Linux glibc 2.17+ x86-64 Details
pgmem-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux musl 1.1+ ARM64, Linux glibc 2.17+ ARM64 Details
pgmem-0.1.4-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details

Total release size: 83.6 MB

Release files / pgmem-0.1.4-py3-none-win_arm64.whl

Download URL pgmem-0.1.4-py3-none-win_arm64.whl
Size 16.2 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
cb9e10effbb1f3150104cbeb70b7ff954fd4118f85be6bf9527596d0f72f42ca
BLAKE2b-256 checksum
How to use checksums
7b66483aa191667fab5e3eb40f51e2fbf109f40a9a1e2d186992c4c5bd0e789c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pgmem-0.1.4-py3-none-win_amd64.whl

Download URL pgmem-0.1.4-py3-none-win_amd64.whl
Size 17.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
77ca24c4adfeda1f94d13d3f19ffd4d8442dddc712f5a1cae6de8300e1a2605f
BLAKE2b-256 checksum
How to use checksums
32a2f826bcdac8889f4ca911eaf4be7f37a5a7e9c4df08f907cd56c8d79f9cc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pgmem-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl

Download URL pgmem-0.1.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Size 17.4 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0878ea964e4c6d981e4e4bbf91dc6ed8d96074697a43e278baade8e53c98f2b0
BLAKE2b-256 checksum
How to use checksums
692341dd1839c9c3ce7ad3dd5120064469a6be478006cc0ef2af917575ee420e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pgmem-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl

Download URL pgmem-0.1.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Size 16.1 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
4ce724c453969d5c5f9ab5c3522e0c957e56591b2e9caf6f9697912964218948
BLAKE2b-256 checksum
How to use checksums
24bec6a062180cea134127ef126ed501e7f26797f38fef98c73cde8c26117859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pgmem-0.1.4-py3-none-macosx_13_0_arm64.whl

Download URL pgmem-0.1.4-py3-none-macosx_13_0_arm64.whl
Size 16.5 MB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
75119759dfa4ca970344b7fd515699abbbfd5dfd05a74bcc90f4dae338b615e3
BLAKE2b-256 checksum
How to use checksums
870e664898621957fe002ca917ec6eab4d3cd44dc24e616676f93190dc0517b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.4 This release

5 release files

0.1.3

5 release files

0.1.2

5 release files

0.1.1

5 release files

0.1.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page