PostgreSQL with zero dependencies
Most Python apps reach for psycopg (a C extension). Larz talks to Postgres with a driver written entirely in the standard library — including modern SCRAM-SHA-256 auth.
pip install larz
from larz.models import connect
connect("postgres://user:pass@localhost:5432/mydb") # ORM now uses Postgres
# sqlite stays the zero-config default:
connect("app.db")
What the driver does
- The PostgreSQL v3 wire protocol — startup, queries, results — over a raw socket.
- SCRAM-SHA-256 authentication (RFC 7677) — the modern Postgres default — plus md5 and cleartext, verified against the spec's test vector.
- Parameterized, injection-safe queries via the extended protocol.
- No psycopg, no libpq, no C extension — just
socket,hashlib,hmac,struct,base64.
The same ORM you use on sqlite runs unchanged on Postgres — it's verified end-to-end against a live PostgreSQL 15 server. sqlite remains the default so small apps stay zero-config.
FAQ
Does it really not use psycopg?
Correct — larz.pg implements the PostgreSQL wire protocol and SCRAM-SHA-256 auth with only the Python standard library. There is no psycopg, no libpq and no C extension.
Is it safe from SQL injection?
Yes — queries are parameterized via Postgres's extended protocol, so values are always sent as data, never interpolated into SQL.
Do I have to switch off sqlite?
No. sqlite is the zero-config default; passing a postgres:// URL to connect() is all it takes to use Postgres instead.