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,040 1,587 935 921 1,577 427
bulk insert 1000 rows 448 180 223 462 76 111
get by primary key 3,078 1,566 942 952 1,565 413
select 1000 rows 728 362 268 680* 331 239
update by primary key 3,035 1,566 935 923 1,573 426
100 users with their posts 1,358 392 245 549 369 110

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

mizzle Tortoise SQLAlchemy ORM SQLAlchemy Core Piccolo Django
insert 1 row 9,831 6,207 2,226 2,827 5,651 4,588
bulk insert 1000 rows 215 120 156 194 66 132
get by primary key 10,112 4,516 2,623 3,182 4,706 3,467
select 1000 rows 898 356 300 846* 390 336
update by primary key 10,516 4,234 2,085 2,779 5,345 4,061
100 users with their posts 655 336 234 472 320 218

* 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. Raw asyncpg, the driver under mizzle, is the upper limit: on single-row work mizzle reaches 97% of it over the network and 67–84% on the same machine. Python 3.14, mizzle 0.2.3, 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, roles, functions and triggers in migrations; streaming, COPY, LISTEN/NOTIFY; 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 on the way.

License

MIT

Metadata

Release files for mizzle 0.2.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.2.3
File Size Uploaded Provenance Actions
mizzle-0.2.3.tar.gz 767.7 kB With provenance Details for mizzle-0.2.3.tar.gz

Built distribution (wheel)

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

Total release size: 936.9 kB

Release files / mizzle-0.2.3.tar.gz

Download URL mizzle-0.2.3.tar.gz
Size 767.7 kB
Tags Source
SHA-256 checksum
How to use checksums
59363900411a8ec54a3c044d129fb8953b36ac6dbf638107c8f00ce0b9cf961d
BLAKE2b-256 checksum
How to use checksums
091216e7d40a23de5045889ecd0c8886cfacab8625eaae28762fba57661489ae
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 3, 2026.

Transparency log

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

Download URL mizzle-0.2.3-py3-none-any.whl
Size 169.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82bce34fb1e47baecbb7af78569abb97975535d94676a552799a11b5f1ea3b1e
BLAKE2b-256 checksum
How to use checksums
bdbc23aad78dbbf319efc901313f24a490befb6f0e5eb0e3a99ee546ca545afc
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 3, 2026.

Transparency log

Security for mizzle 0.2.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.2.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 3, 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