Registry / testing / py-pglite

py-pglite

JSON →
library0.5.3pypypiunverified

Python testing library for PGlite - an in-memory PostgreSQL for tests. Provides a lightweight, in-process PostgreSQL via WebAssembly (pglite-manager). Current version 0.5.3, requires Python >=3.10. Active development with monthly releases.

pip install py-pglite
INSTALL
IMPORT
SIG · PY-PGLITE
P
py-pglite
testingpythonv0.5.3
Install
1.8s avg
Import
Disk
16MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 1.8s
py 3.11
✓ —
✓ 1.8s
py 3.12
✓ —
✓ 1.7s
py 3.13
✓ —
✓ 1.7s
py 3.9
✕ build_error
✕ build_error
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PGlite
from py_pglite import PGlite
from pglite import PGlite
PGliteManager
from py_pglite import PGliteManager
get_client
from py_pglite import get_client

Basic usage: spin up ephemeral PostgreSQL and run a query.

import pglite # Start an in-memory PostgreSQL instance db = pglite.PGlite() # Get a psycopg2 connection string conn_str = db.get_connection_string() print(conn_str) # Connect using psycopg2 import psycopg2 conn = psycopg2.connect(conn_str) cur = conn.cursor() cur.execute("SELECT version();") print(cur.fetchone()[0]) cur.close() conn.close()
Debug
Known issues
breakingIn v0.5.0, the API changed from sync-only to support async via SQLAlchemy async engine. The synchronous connection string methods still work, but async users must use get_engine(driver='asyncpg').
fix
For async SQLAlchemy: engine = db.get_engine(driver='asyncpg')
affects: >=0.5.0
gotchaPGlite launches a Node.js child process (pglite_manager.js). If your Python process exits uncleanly, orphaned processes may remain. Since v0.5.3, cleanup is improved, but always call db.close() or use the context manager.
fix
Use context manager: with pglite.PGlite() as db: ...
affects: <0.5.3
gotchaThe database is ephemeral and lives only as long as the PGlite instance. Data is lost when the Python process ends or PGlite is garbage collected.
fix
Do not use for production data. Designed for tests only.
affects: all
gotchaExtensions like pgvector require opt-in via the 'extensions' parameter. They are not enabled by default.
fix
db = pglite.PGlite(extensions=['vector'])
affects: >=0.4.0
Upgrade
Version history
0.5.3latest on PyPI · released Sep 17, 2025
Audit
Dependencies
psycopg2-binaryoptionalDefault PostgreSQL driver used by py-pglite
SQLAlchemyoptionalFor SQLAlchemy engine/connection integration
asyncpgoptionalFor async PostgreSQL support
djangooptionalFor Django test runner integration
psycopgoptionalAlternative modern driver (psycopg 3)
Agent activity
16 hits · last 30 days
node
14
Resources
py-pglite — pip install py-pglite · libregistry