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

Metadata

Release files for pgmem 1.18.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 1.18.1
File Actions
pgmem-1.18.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for pgmem-1.18.1-py3-none-win_arm64.whl
pgmem-1.18.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for pgmem-1.18.1-py3-none-win_amd64.whl
pgmem-1.18.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 for pgmem-1.18.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64.whl
pgmem-1.18.1-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 for pgmem-1.18.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl
pgmem-1.18.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details for pgmem-1.18.1-py3-none-macosx_13_0_arm64.whl

Total release size: 83.6 MB

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

Download URL pgmem-1.18.1-py3-none-win_arm64.whl
Size 16.2 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
6f03d44bfbea199583e8158aa92d068ed70468c1ad6fd707ef1a53f122f43762
BLAKE2b-256 checksum
How to use checksums
702ba9247095a1d7ccbd7c1d7e7613e736ceaf5600e9ba369269253ac12ff413
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 Oct 2, 2026.

Transparency log

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

Download URL pgmem-1.18.1-py3-none-win_amd64.whl
Size 17.5 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
cc30926b35cff973f70be6818c9b90d20e2fbf3ea2e206cb2150e0fd25bd7a85
BLAKE2b-256 checksum
How to use checksums
bff6d6c50324884d1296ca1f5d65491ac18da44840a13f19adc701357477dc82
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 Oct 2, 2026.

Transparency log

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

Download URL pgmem-1.18.1-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
e6b5aebfb2dd1ec5b9a7e66dcd8374dee13101e34d06331318f378580c320950
BLAKE2b-256 checksum
How to use checksums
aeb8c27030a141691417784304c67b86bcc012386988bd9a46acf42983ee86a9
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 Oct 2, 2026.

Transparency log

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

Download URL pgmem-1.18.1-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
ecf9d28b6f1929bf282b18e605ac7d4216396845b85fb277932a29ef383973b0
BLAKE2b-256 checksum
How to use checksums
a4cbf13e4d134dba42df17807b5f49c3b665a07e5b0673618ccb51f807d4b728
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 Oct 2, 2026.

Transparency log

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

Download URL pgmem-1.18.1-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
37dc306f32eb411cbd1534b41138dc268f1f3df9c34c7a62fdb7e5e0a6a1a958
BLAKE2b-256 checksum
How to use checksums
007d0a93c0dc35242ede17ac704c01aca697b4f61a0a63b38a061964135c67e6
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 Oct 2, 2026.

Transparency log

Security for pgmem 1.18.1

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for pgmem-1.18.1-py3-none-win_arm64.whl

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 Oct 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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