mizzle
A fully typed, async ORM for Python and PostgreSQL: write queries that read like SQL, get typed rows back, and evolve your schema with generated migrations. If you know Drizzle from TypeScript, mizzle will feel familiar.
- Schema in Python classes. Result rows are typed for pyright and mypy, with no code generation.
- Two query styles: a SQL-like builder (
select,insert,update,delete, joins, CTEs, upserts) and relational queries that load nested data in one SQL statement. - Migration kit:
generate,migrate,push,pull,check,drop,typegen. - Studio: browse and edit data in your browser (
mizzle studio). - Safe by default: values are always bind parameters,
update/deleterefuse to run without.where(), migrations are locked, transactional and tamper-checked, and errors never include row values.
Built for PostgreSQL first; other SQL databases plug in through the dialect layer
(src/mizzle/dialects/).
A complete example app (FastAPI, migrations, seed data, tests) lives in
examples/social.
Install
pip install mizzle # ORM + migration CLI
pip install "mizzle[studio]" # + Studio (its UI downloads into your venv on first run, ~250 KB)
Schema
# app/db/schema.py
import enum
from typing import final, override
from mizzle import Table, index, many, one, sql
from mizzle.pg import integer, pg_enum, serial, text, timestamp, varchar
class Role(enum.StrEnum):
ADMIN = "admin"
USER = "user"
@final
class Users(Table, name="users"):
id = serial().primary_key() # Column[int]
email = varchar(255).not_null().unique() # Column[str]
bio = text() # Column[str | None]
role = pg_enum(Role).not_null().default(Role.USER) # Column[Role]
created_at = timestamp(tz=True).not_null().default(sql("now()"))
posts = many(lambda: Posts)
@final
class Posts(Table, name="posts"):
id = serial().primary_key()
author_id = integer().not_null().references(lambda: Users.id, on_delete="cascade")
title = text().not_null()
author = one(lambda: Users, fields=lambda: [Posts.author_id], references=lambda: [Users.id])
@classmethod
@override
def config(cls):
return [index("posts_author_idx").on(cls.author_id)]
Queries
from mizzle import Database, desc, eq
async with await Database.connect("postgresql://...", schema=[Users, Posts]) as db:
[ann] = await db.insert(Users).values(email="ann@x.io").returning() # Users
admins = await db.select().from_(Users).where(eq(Users.role, Role.ADMIN)) # list[Users]
pairs = await (
db.select(Users, Posts).from_(Users).left_join(Posts, eq(Posts.author_id, Users.id))
) # list[tuple[Users, Posts | None]]
# Relational: one SQL statement, typed nested results.
users = await db.query(Users).find_many(
with_={"posts": {"order_by": desc(Posts.id), "limit": 5}},
)
users[0].posts[0].title # str
async with db.transaction() as tx:
await tx.update(Users).set(bio="hi").where(eq(Users.id, ann.id))
Raw SQL: sql(t"select * from users where id = {user_id}") (Python 3.14+) or
sql("... where id = {}", user_id). Values become bind parameters. Never build the text
passed to sql() from user input (for example with an f-string).
Migrations
mizzle init creates mizzle.toml, a starter schema module and the migrations folder
(--pyproject puts the settings in [tool.mizzle] of pyproject.toml instead):
schema = "app.db.schema" # module(s) with your tables
out = "migrations" # commit this folder
url_env = "DATABASE_URL" # the URL is read from the environment
mizzle init # set up mizzle.toml, db/schema.py and migrations/
mizzle generate # write migrations/0001_.../migration.sql + snapshot.json
mizzle migrate # apply pending migrations (safe with many app servers)
mizzle push # dev: sync schema straight to the database
mizzle pull # existing database -> your schema module (or pulled_schema.py next to it)
mizzle check # find broken or clashing migrations
mizzle drop # delete the latest, unapplied migration
mizzle typegen # TypedDicts for insert/update values
mizzle studio # open Studio
Renames: on a terminal, generate asks whether a new column is a rename. In CI pass
--rename users.name=full_name. Changes that can lose data need confirmation or
--allow-data-loss. From code: await mizzle.kit.migrate(db, "migrations").
Development
docker compose up -d
export MIZZLE_TEST_URL=postgresql://mizzle:mizzle@localhost:54329/mizzle
uv run pytest # integration tests skip when MIZZLE_TEST_URL is unset
uv run pyright && uv run mypy
uv run ruff check && uv run ruff format --check
cd studio-ui && pnpm install && pnpm build # builds the UI into src/mizzle/studio/static
pnpm dev # UI dev server; proxies /api to `mizzle studio`
pnpm check # Biome: format, lint, sort imports (--write)
Releases: push a v* tag. .github/workflows/release.yml builds the UI, packages it into
the wheel, and publishes to PyPI with trusted publishing.
Metadata
Release files for mizzle 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mizzle-0.1.0.tar.gz | 576.3 kB | With provenance | Details for mizzle-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mizzle-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mizzle-0.1.0-py3-none-any.whl |
Total release size: 669.4 kB
Release files / mizzle-0.1.0.tar.gz
| Download URL | mizzle-0.1.0.tar.gz |
|---|---|
| Size | 576.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8853daa608331b178c3ca81cbcce5511ef58cc8786748242cae229c39ef964f8
|
|
BLAKE2b-256 checksum How to use checksums |
7ec65e59545edab9dba67afed9bf75457bb6479f6187f488ed39f2045469163b
|
| 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 2, 2026.
Transparency logRelease files / mizzle-0.1.0-py3-none-any.whl
| Download URL | mizzle-0.1.0-py3-none-any.whl |
|---|---|
| Size | 93.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da8ec911eb2d0dce83bba8ee468ee4a95f7e9db78aad2daabf968bf5ced0748c
|
|
BLAKE2b-256 checksum How to use checksums |
acc780b0afb995f9e99ca992c49220c9f4ffc619424a94316907498c0fa104b3
|
| 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 2, 2026.
Transparency logSecurity for mizzle 0.1.0
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.
Attestation for mizzle-0.1.0.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 2, 2026.
Transparency logA 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.