ormar · one Python model for your database and your API
4 months ago
Ormar is an async ORM for Python, built with FastAPI in mind. Its one big idea: a single model class is both your database table and your Pydantic schema. So you stop writing and syncing two models for every table. Let's build one.
Ask about this presentation
Chapters
Show transcriptHide transcript
Ormar is an async ORM for Python, built with FastAPI in mind. Its one big idea: a single model class is both your database table and your Pydantic schema. So you stop writing and syncing two models for every table. Let's build one.
Normally you keep two things in step: an ORM model for the database, and a separate Pydantic model for validation and your API. In ormar, they are the same class. Define it once, and it does both jobs.
Start with one config that holds your database connection and metadata. Then declare your models. Here, an Author, and a Book. Add a single foreign key, and the two models are linked. The type hints are plain Python, so your editor and mypy understand them.
Everything is async, so you await your calls. Create an author, then create a book that points at that author. To load the relation, use select related. One call joins the tables, and then you just walk the relationship in Python: book, author, name.
The reverse side is free. Ormar names it for you, so an author carries a list of their books. And filtering feels familiar: double-underscore lookups reach right across the relation. Ask for a book that isn't there, and you get a clean NoMatch.
Here is where one model pays off. In FastAPI, pass your ormar model straight in as the request body. And return it as the response model. Same class, both directions. There is no second schema to define or keep in sync.
That is the core. From here ormar gives you many-to-many relations, joins and aggregations, Alembic migrations, and full mypy support. Install it with pip install ormar, and explore the rest of these docs.
Up next
2:03cargo-nextest · a next-generation test runner for Rust
@github
4 months ago
1:35mq · jq, but for Markdown
@github
4 months ago
1:24Mimesis · realistic, locale-aware fake data in one line
@github
4 months ago
1:38pikepdf · open, edit and repair PDFs in Python, losslessly
@github
4 months ago
1:22tfswitch · the right Terraform version, automatically
@github
4 months ago
1:21PyPDFForm · fill a PDF form in Python in a few lines
@github
4 months ago
1:35MCP-UI - interactive apps for MCP tools
@github
4 months ago
1:39workmux - parallel coding agents in isolated worktrees
@github
4 months ago
1:33Pumpkin - start a Rust Minecraft server
@github
4 months ago
1:39Bifrost - your first reliable AI gateway
@github
4 months ago
1:39Honcho - memory that reasons across sessions
@github
4 months ago
1:56agentgateway · one governed proxy for your agent traffic
@github
4 months ago






