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.1

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.1
File
pgmem-0.1.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
pgmem-0.1.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pgmem-0.1.1-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-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux musl 1.1+ ARM64 Details
pgmem-0.1.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details

Total release size: 83.1 MB

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

Download URL pgmem-0.1.1-py3-none-win_arm64.whl
Size 16.1 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
7f0ab5d58bde4fe461922a14274c8d1355888055d2c87f3ccf2d7e4770ae5587
BLAKE2b-256 checksum
How to use checksums
8d32f4ba3bdd032d5fa6c8be99363515538a82e48c94e25c13904e0de5110de9
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 17, 2026.

Transparency log

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

Download URL pgmem-0.1.1-py3-none-win_amd64.whl
Size 17.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
19799b38a89646ec9b3c47293e4e155d3c356d6e3f98b8afe62893597e09199c
BLAKE2b-256 checksum
How to use checksums
19f328b9da8b923edbbf66d5fabb28a9246e2f722e5d5fdd7287eb4c336ed712
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 17, 2026.

Transparency log

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

Download URL pgmem-0.1.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
Size 17.2 MB
Tags Linux glibc 2.17+ x86-64 Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
201d3f3897a2c65f4364d4e8972c6d891cbe2ee56abac0915c23d84ef280367e
BLAKE2b-256 checksum
How to use checksums
61bddaa6fd690bb04b423d6b8f2c88fed09e580b3396d9a996719164c64610f7
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 17, 2026.

Transparency log

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

Download URL pgmem-0.1.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
Size 16.0 MB
Tags Linux glibc 2.17+ ARM64 Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
12b71d8721e9e5573e4078bbfcb94ea344bfa9ab7c1e161f454ea4d41d04a248
BLAKE2b-256 checksum
How to use checksums
99b9eae427e7f711c69152a93c4f3d80375f7a89c99b053fbab6cd449bf4439e
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 17, 2026.

Transparency log

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

Download URL pgmem-0.1.1-py3-none-macosx_13_0_arm64.whl
Size 16.4 MB
Tags Python 3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
00c8d9c0c9298eba347a4fb212b26a003f660700d608f2f142fc0c9094e7e661
BLAKE2b-256 checksum
How to use checksums
e7d398e2fa58e5fa88c086e1b884988d8d0a20ca057f5e7c723c72a45117c051
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 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.4

5 release files

0.1.3

5 release files

0.1.2

5 release files

This release

0.1.1 This release

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