Skip to main content

mizzle

Fully typed async ORM for Python and PostgreSQL

GitHub • PyPI • Example app • Releases


What's mizzle?

mizzle is an ORM for people who like SQL. You describe tables as Python classes and write queries that read like the SQL they produce. Every row comes back typed, so your editor and type checker know user.email is a str — no code generation, no plugins.

It is async from the ground up, built on asyncpg, with one runtime dependency. Values are always sent as bind parameters, update and delete refuse to touch a whole table by accident, and database errors never leak your data into logs.

Need nested data? Relational queries load a user with their posts and comments in a single SQL statement, typed all the way down.

Ecosystem

mizzle CLI generates SQL migrations from your schema, applies them safely (even with many app servers starting at once), pushes changes straight to a dev database, and pulls an existing database into Python code.

mizzle studio opens your database in the browser to browse, filter and edit data.

Quick look

pip install mizzle
mizzle init        # creates mizzle.toml, db/schema.py and migrations/
from typing import final

from mizzle import Database, Table, eq, sql
from mizzle.pg import serial, text, timestamp, varchar


@final
class Users(Table, name="users"):
    id = serial().primary_key()
    email = varchar(255).not_null().unique()
    bio = text()
    created_at = timestamp(tz=True).not_null().default(sql("now()"))


async with await Database.connect("postgresql://...", schema=[Users]) as db:
    [ann] = await db.insert(Users).values(email="ann@example.com").returning()
    users = await db.select().from_(Users).where(eq(Users.id, ann.id))  # list[Users]
mizzle generate    # write a migration from your schema
mizzle migrate     # apply it
mizzle studio      # browse the data

In production

db = await Database.connect(
    "postgresql://...",
    schema=[Users],
    replicas=["postgresql://replica-1/...", "postgresql://replica-2/..."],
    pool_size=20,
    query_timeout=5,  # seconds; slow queries raise QueryTimeout
)

await db.select().from_(Users)  # reads go to the replicas, in turn
await db.primary.select().from_(Users)  # read your own write right away
await db.retry(transfer)  # re-run a transaction on a serialization conflict

Writes, transactions and FOR UPDATE always use the primary. Behind PgBouncer in transaction mode, pass statement_cache_size=0. CI tests a real streaming replica and PgBouncer on every change.

Benchmarks

Operations per second, higher is better: the same queries on the same PostgreSQL 18 database, median of 5 rounds (benchmarks/bench.py).

A busy app: 50 concurrent clients, 8 connections per library, and 1 ms of network latency each way (2.2 ms round trip, like a database on another server):

mizzle Tortoise SQLAlchemy ORM SQLAlchemy Core Piccolo Django
insert 1 row 3,060 1,565 922 907 1,552 423
bulk insert 1000 rows 328 180 224 456 75 115
get by primary key 3,074 1,558 937 955 1,563 412
select 1000 rows 1,726 297 263 677* 415 233
update by primary key 3,041 1,563 916 911 1,570 424
100 users with their posts 1,327 384 238 540 373 106

One client, database on the same machine (0.05 ms round trip, 4 connections):

mizzle Tortoise SQLAlchemy ORM SQLAlchemy Core Piccolo Django
insert 1 row 12,859 6,586 2,356 2,849 4,924 4,680
bulk insert 1000 rows 214 125 165 207 62 140
get by primary key 10,178 4,900 2,733 3,177 4,733 3,555
select 1000 rows 1,072 319 311 837* 382 377
update by primary key 9,278 4,301 2,127 2,771 5,168 3,972
100 users with their posts 650 320 219 453 302 212

* SQLAlchemy Core returns plain tuples; the ORMs build full row objects.

mizzle loads nested rows in one statement, so it pays one round trip where the others pay two (over the network that beats even hand-written asyncpg doing two queries). Against raw asyncpg, the driver under mizzle, it reaches 97–99% over the network (bulk insert: 54%) and 71–93% on single rows on the same machine. Python 3.14, mizzle 0.2.4, Tortoise 1.1.9, SQLAlchemy 2.1.6, Piccolo 1.39.0, Django 6.1.3 (its async ORM runs queries in one thread, on psycopg). The script's docstring explains each library's setup and the latency proxy. Run it yourself:

docker compose up -d
uv run --with tortoise-orm --with "sqlalchemy[asyncio]" --with piccolo --with django \
  --with "psycopg[binary,pool]" python benchmarks/bench.py
BENCH_CLIENTS=50 BENCH_POOL=8 uv run ...  # the concurrent run

What else is in the box

Joins, subqueries, CTEs, window functions, UNION, CASE and typed SQL functions; identity, generated and auto-updated columns; pgvector and full-text search; views, row-level security, policies and roles in migrations (custom migrations for the rest); streaming and batched inserts; read replicas, timeouts and retries. See the changelog for examples.

Learn more

The example app is a complete FastAPI service built with mizzle: schema, migrations, relational queries, Pydantic models, seed data and tests. Full documentation is at mizzle.readthedocs.io, with llms.txt for LLM tools.

License

MIT

Metadata

Release files for mizzle 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mizzle 0.3.3
File Size Uploaded Provenance Actions
mizzle-0.3.3.tar.gz 987.9 kB With provenance Details for mizzle-0.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mizzle 0.3.3
File Interpreter ABI Platform Actions
mizzle-0.3.3-py3-none-any.whl Python 3 none any Details for mizzle-0.3.3-py3-none-any.whl

Total release size: 1.3 MB

Release files / mizzle-0.3.3.tar.gz

Download URL mizzle-0.3.3.tar.gz
Size 987.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1a408f184b731d3660e555854b2c3de01185c5fbac29fdf199dafd593516b452
BLAKE2b-256 checksum
How to use checksums
512c120451887664f235eee267d992ddb10f29eea0c72f005e284fbd26d23d43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Release files / mizzle-0.3.3-py3-none-any.whl

Download URL mizzle-0.3.3-py3-none-any.whl
Size 263.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2e770987ffbf09f419a430334b5b68c543b37b954f10b6ac3e60c82a5c4db2f
BLAKE2b-256 checksum
How to use checksums
65e60656cc7b399ba277f7e5515f087dbe7fb744a632fbce6bb3fe870c72e6df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Security for mizzle 0.3.3

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mizzle-0.3.3.tar.gz

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 Nov 9, 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