Rust-powered PostgreSQL driver and Django database backend.
Project description
django-vpg
Status: Experimental. Freshly extracted from glitchtip-rust, where the driver runs GlitchTip in production — but this standalone package is new, not yet on PyPI, and its API and packaging may change without notice. Evaluate freely; don't bet production on it yet.
A Rust-powered PostgreSQL driver and Django database backend.
django-vpg replaces the connection/cursor IO layer of Django's stock
PostgreSQL backend with a Rust core (tokio-postgres + deadpool, via PyO3):
swap one ENGINE line, keep your schema, migrations, and ORM code
unchanged.
Part of the django-v* family — django-vcache, django-vtasks, django-vpg — small, fast, Rust-core Django infrastructure maintained by the GlitchTip team. django-vcache and django-vtasks are battle-tested in production at glitchtip.com; django-vpg is the newest member. (The v originally stood for Valkey; with three packages it now just marks the family.)
Why
- CPU and RSS. Protocol parsing, row decoding, and type marshalling run in Rust; only final Python values are materialized — intermediate protocol buffers and COPY encoding never traverse the Python heap. In the GlitchTip team's A/B benchmarks against psycopg (production-shaped ingest workloads, replayed locally), the driver holds resident memory flat under heavy-tailed payloads where libpq's buffers ratchet (2.5 vs 21 MB growth per 10k events), and wins per-op CPU on jsonb reads, pipelined batch inserts, and COPY event batches.
fetch_modelsfusion. Row → model-instance materialization can run as a single driver call instead of a per-row Python loop.- COPY at native speed.
COPY FROM STDINwith batch text-format encoding in Rust (encode_copy_chunk). - psycopg-shaped errors. Full PEP 249 exception hierarchy with
sqlstateandDiagnostics, so existing error-handling code ports cleanly. - Server-side cancellation. Cancelled queries fire a PostgreSQL
CancelRequeston a fresh connection and the pooled connection returns clean — no poisoned pool state, no abandoned server work. - Real pooling. deadpool checkout/return with warmup, wait timeouts,
and jittered max-lifetime recycling; prepared-statement cache with
psycopg3-style admission (
prepare_threshold/prepared_max); pgbouncer mode (OPTIONS={"pgbouncer": True}, which disables prepared statements). - libpq-parity TLS.
sslmode(disable/allow/prefer/require/verify-ca/verify-full),sslrootcert, client certificates.
Install
pip install django-vpg # sync ORM + async driver API
pip install django-vpg[async] # + async ORM via django-async-backend (Django 6+)
Note: psycopg (the library) must be installed — it is a declared
dependency. Django's stock postgresql backend, which django-vpg
subclasses for schema/introspection/operations, imports it at load time.
The IO path never uses it.
Quickstart
DATABASES = {
"default": {
"ENGINE": "django_vpg.backend",
"NAME": "mydb",
"USER": "postgres",
"PASSWORD": "...",
"HOST": "db.example.com",
"PORT": "5432",
# Optional driver OPTIONS (libpq-parity naming; psycopg3-compatible
# pool dict):
# "OPTIONS": {
# "pool": {"max_size": 20, "min_size": 2}, # default max_size: 10
# "sslmode": "verify-full",
# "sslrootcert": "/path/ca.pem",
# },
}
}
Supported OPTIONS keys: pool (psycopg3-compatible dict — max_size,
min_size, timeout, max_lifetime, max_idle, name — or False for
a dedicated single-slot connection per Django connection, e.g. under test
runners), pool_size (shorthand for pool={"max_size": N}; default 10),
pgbouncer, isolation_level, application_name, connect_timeout,
keepalives, keepalives_idle, prepare_threshold, prepared_max,
sslmode, sslrootcert, sslcert, sslkey, and server_settings.
Unknown keys warn once and are dropped.
The async story (three layers)
- Sync ORM — stock Django, zero extra deps. Works everywhere Django works.
- Async driver API — real asyncio, works anywhere. The raw driver
(
django_vpg._driver.RustPgDriver) exposesawait-able query, execute, transaction, and COPY operations with no dependency on any async framework beyond asyncio itself; driver awaitables interoperate withgather,wait_for,shield, and cancellation. (django_vpg.dbapiitself is the sync DB-API 2.0 shim the Django engine builds on.) - Async ORM — via django-async-backend. Installing the
django-vpg[async]extra activatesAsyncDatabaseWrapper, which plugs into theasync_connectionsframework. Without it, the backend cleanly degrades to sync-only (no ImportError).
Unifying Django's connections and async_connections (transaction
management and isolation across both worlds) is active upstream work in
django-async-backend that this package tracks closely.
The tokio runtime
The driver runs on a fork-safe shared tokio runtime owned by the package
(1 worker thread by default; VPG_TOKIO_WORKER_THREADS overrides). Prefork
servers are safe: the runtime is rebuilt per child on first use.
Rust embedders get the same hook django-vcache offers: link vpg-pyo3 as
an rlib, re-export its pyclasses into your own pymodule, and install a
process-wide runtime with vpg_core::set_runtime_provider(my_get_runtime)
so one tokio pool serves every driver in the process. This mirrors how
glitchtip-rust embeds its driver today (rlib link + re-exported
pyclasses + one shared runtime); gt_rust will switch to linking vpg-pyo3
and installing its runtime via this hook.
Status
Extracted from glitchtip-rust (v0.6.1), where this driver is the only database engine in GlitchTip's backend (as of July 2026). Pre-1.0 while the standalone packaging settles; the driver core predates this package and carries its full test suite (including an in-process PG wire-server harness) with it.
Known naming wart: the vendored tokio-postgres buffer-cap patch reads the
GT_PG_BUF_CAP_BYTES env var (512 KiB default retained-buffer cap); it
will be renamed with a compatibility window before 1.0.
Development
./scripts/check.sh # fmt + clippy -D warnings + cargo test + ruff
# (includes tests/wire.rs — an in-process scripted
# PG wire server; no live postgres needed)
# Python suite (needs maturin + a live postgres for the marked tests):
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest pytest-asyncio django psycopg django-async-backend
maturin develop --release
VPG_TEST_DSN=postgres://postgres@localhost:5432/postgres python -m pytest tests/
The workspace is two crates: crates/vpg-core (pure Rust, no pyo3,
cargo test-able) and crates/vpg-pyo3 (thin bindings, cdylib + rlib).
vendor/tokio-postgres carries a minimal retained-buffer-capacity patch —
see vendor/tokio-postgres/GT_PATCH.md for rationale and the re-audit
procedure on version bumps.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_vpg-0.1.0.tar.gz.
File metadata
- Download URL: django_vpg-0.1.0.tar.gz
- Upload date:
- Size: 251.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
382950b6c572cc0199ff807f0ee94db65217227541bb8461681dbff6568d5280
|
|
| MD5 |
7300174c6a1b62ffe792fe5ddd72d89a
|
|
| BLAKE2b-256 |
00ee9a82c68137270cfd88f4ce8f3616323e54e5f08926c87b64c722ecfd51c8
|
File details
Details for the file django_vpg-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb314b31b06a564684241e2f78af4cdd94a98e96ad731c924fe589bde85ef3b3
|
|
| MD5 |
5ba3ea56373968e01b2b73bbadffaf2b
|
|
| BLAKE2b-256 |
a560418371e811332bd638b3048e563d67437384180fb60ae689f438e5004885
|
File details
Details for the file django_vpg-0.1.0-cp314-cp314-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp314-cp314-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.14, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f17eb36f4470c16512f6f06f043f256733aaa1f584085ee65b8b93420209df3f
|
|
| MD5 |
9c610d777567aeedf4ec30b4905d6494
|
|
| BLAKE2b-256 |
c01b4d3e81ae95dbcf86a6d2bf2d202e96ddbdb62988d2948e6427b9cbc3ea83
|
File details
Details for the file django_vpg-0.1.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1612d254194413b9f4ae316493e1c07514929b886aadb5ea73c78e8203a376b
|
|
| MD5 |
c39f4b5aab671ca45557a3b66532c35e
|
|
| BLAKE2b-256 |
2bc4e361a55748f4e2dfb07c3d031d80b41f870a92766cc7b6cd4344fdc7a65e
|
File details
Details for the file django_vpg-0.1.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e338ba72d032fdef60c97e785f6d501ae1013ea266c449196d3bc6e72bbb672
|
|
| MD5 |
341be7881978a8da5c4731ede7660114
|
|
| BLAKE2b-256 |
fc69f6f856427e64923fa6aaca8dfba442b2e5bb35a4660eb650551994f6f205
|
File details
Details for the file django_vpg-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef6920492929b120bb793b265bf5db06b59f6cb660cdbc6931285f4132b780a3
|
|
| MD5 |
e0f0427dfb917c7576d5566f95f7f462
|
|
| BLAKE2b-256 |
b4401a98140e98e0d18aa66ef8b3691b1716093ec762afed055bf84de1eb9be3
|
File details
Details for the file django_vpg-0.1.0-cp313-cp313-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp313-cp313-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eee25c74fcc0e1cba56ea07103ec7775bf1fde5e5e8671f679757f450dd50cc6
|
|
| MD5 |
7af4de9af188752ce1ad53bc266f9e7a
|
|
| BLAKE2b-256 |
0abb81cc21a7a004e9ee5a41d864b389a3c0dd0a092371a175c43b8df6cc7e1a
|
File details
Details for the file django_vpg-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbacbeca66f7713140ca355a5c12a458252530c14fc437f34c7805c3112f4fa0
|
|
| MD5 |
b8f351e6b5e3b25b32608404f83ce059
|
|
| BLAKE2b-256 |
e79006f3a4b4f9131601409f5cf1c03ae2d7edc5d13fc5d90d2ca159d045f430
|
File details
Details for the file django_vpg-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b14a37c51fcb08b68be9b0f1de84705af75f2fe2356f121c1fa94b17379deef
|
|
| MD5 |
b65ee377d814f833bcc7f10a1594540a
|
|
| BLAKE2b-256 |
fb8ab7afa2a36814aaf10a49e2c8a8241d6fe61883896a71c25057b219a99bf4
|
File details
Details for the file django_vpg-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e11e6711e3d692ad4e9359b5df0aa8576c6fa3a65c6503a5f0dbba18ae47d905
|
|
| MD5 |
ec6cf8d1564e8390018c23bbbecdebb2
|
|
| BLAKE2b-256 |
1ffb4f07f8cf8b2491cafa585a643d2593580f7be915df327a5b79ab2fc58264
|
File details
Details for the file django_vpg-0.1.0-cp312-cp312-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp312-cp312-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94d72b229e77ee3dda7ea6e7e23d4770082e08ca8e75f9ef8086895f0dde15c3
|
|
| MD5 |
d00ce49a93be38b23b702fca0822967d
|
|
| BLAKE2b-256 |
46d184203bbede364f7d814c71437f45a165cafbe53bdf6491f55470c2beb37a
|
File details
Details for the file django_vpg-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6c956ffe05a786a1ac996b9ac171aa0ce038d1faeafb0304a9b68ed743e8dc7
|
|
| MD5 |
f989ac31a83dc182728bf12933987d13
|
|
| BLAKE2b-256 |
c0ed98ff50e675e523df40d070eb8dac2c4515babcc7075d4e2622addb2cbfca
|
File details
Details for the file django_vpg-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: django_vpg-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdfa52ebbb4e84a5d34c9b524aa6ac22559a3562f203c54840e3dd52e0fa69ab
|
|
| MD5 |
8115bb19dc3e9f6aef8d34caf9776b55
|
|
| BLAKE2b-256 |
48675bb4d12c4be2f0ceecb756dc3217dfba10349829ca02a13078128c83477a
|