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 1.18.0

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 1.18.0
File
pgmem-1.18.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
pgmem-1.18.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pgmem-1.18.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux musl 1.1+ x86-64 Details
pgmem-1.18.0-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-1.18.0-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details

Total release size: 83.6 MB

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

Download URL pgmem-1.18.0-py3-none-win_arm64.whl
Size 16.2 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
64840a9f93f497e998c25b644b3dc4e4bbdb6ca4a73c203fa71ace3f2d192bc8
BLAKE2b-256 checksum
How to use checksums
3d1e109de5d1d160fa41033a16bb059ca21f5993af7bf4f5166deac3ab073e32
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 28, 2026.

Transparency log

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

Download URL pgmem-1.18.0-py3-none-win_amd64.whl
Size 17.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
8ec0ed18715f1b55465e3d5fba1048fbcb799ad55d8a73897a7cb4152979ad9a
BLAKE2b-256 checksum
How to use checksums
57ede8fa77fce35e1b4e0b7d0feb48b6e419ff5f035d93bb20c1a049bbdc7ba8
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 28, 2026.

Transparency log

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

Download URL pgmem-1.18.0-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
639e709ec97ac15375af856789086eeaaf9827e0995c3b015793e046354268f0
BLAKE2b-256 checksum
How to use checksums
913273f56c78d797b162b6ac31492329fc463beb2e9ede7ed7be2ef810633c34
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 28, 2026.

Transparency log

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

Download URL pgmem-1.18.0-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
45ae50adf1825ee15306d2270ff0d51f9d8c2da1eeb53001d8ff0b340a84c250
BLAKE2b-256 checksum
How to use checksums
3699a65adf95d41c24333c288f1e919b06fdf478bac584f3e4f55910f1bc5142
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 28, 2026.

Transparency log

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

Download URL pgmem-1.18.0-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
d37c8ee9181d72dfeca1334d279217177d385dda9e5a0ce1f19a3ff1d9052300
BLAKE2b-256 checksum
How to use checksums
6aadd3e6967b572d4d54da9531e289b10f20138ded6dce9db7b566061f43c65a
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 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.18.0 This release

5 release files

0.19.0

5 release files

0.1.4

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