ormar
An async ORM with fastapi in mind and pydantic validation.
What it is and what it does
Ormar is an async ORM built on SQLAlchemy core that lets you define a single model class that serves both as a database schema definition and as a pydantic validation schema. This eliminates the common pattern of maintaining separate ORM models and request/response validation schemas. It supports Postgres, MySQL, and SQLite through async drivers, making it a natural fit for async web frameworks like FastAPI and Starlette.
The package integrates pydantic's validation layer directly into the ORM, so your model fields are both database columns and validated request/response fields. You define relationships, constraints, and field types once, then use the same model class for database queries, API request bodies, and API responses. It handles async database operations throughout—queries, inserts, updates, and relationship loading all use await syntax.
Use it for:
- Build FastAPI applications where the same model class validates incoming requests and represents database records.
- Create async web services that need to query Postgres, MySQL, or SQLite without maintaining parallel pydantic and ORM schemas.
- Migrate existing SQLAlchemy projects to async using the sqlalchemy-to-ormar translation tool.
- Define relationships and foreign keys in a single model that automatically works as both ORM and API schema.
- Use with fastapi-crudrouter or fastapi-pagination for automatic CRUD endpoints and pagination support.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
An async ORM for Python that unifies database models with pydantic validation, designed to work directly with async web frameworks like FastAPI without maintaining separate ORM and validation schemas.
Yes, if you are building async Python applications with FastAPI or similar frameworks and want to reduce schema duplication. The package is actively maintained, has no known vulnerabilities, and low install friction. The beta status reflects ongoing development rather than instability—it has been in active use since 2020 and receives regular updates. Pin the version (e.g., ormar~=0.26.0) as recommended, and read release notes before upgrading since major version changes introduce breaking changes.
Install
ormar on PyPI
pip
pip install ormaruv
uv add ormarpoetry
poetry add ormarInstalling ormar
Before you install
Low friction installation with a pure-Python wheel. The package is actively maintained with a recent release and no known vulnerabilities. It depends on four runtime packages (SQLAlchemy, orjson, ormar-utils, pydantic) that are themselves well-established.
License in practice
MIT license permits commercial and private use with minimal restrictions. The package is explicitly open-source and free, with the maintainer accepting sponsorship but making no license-based demands.
Quickstart
import ormar
import sqlalchemy
DATABASE_URL = "sqlite+aiosqlite:///db.sqlite"
base_config = ormar.OrmarConfig(
database=ormar.DatabaseConnection(DATABASE_URL),
metadata=sqlalchemy.MetaData(),
)
class Author(ormar.Model):
ormar_config = base_config.copy(tablename="authors")
id: int = ormar.Integer(primary_key=True)
name: str = ormar.String(max_length=100)
Requires Python 3.10 or later. Async operations must be awaited within an async context (e.g., inside an async function or FastAPI route handler).
Verify before relying
- Whether the package's beta status (Development Status :: 4 - Beta) indicates stability concerns or is simply conservative labeling.
- Performance characteristics when working with large result sets or complex queries.
- How well migration tooling (alembic integration) handles schema evolution in production.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0.0,>=3.10.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — SQLAlchemy, orjson, ormar-utils, pydantic |
| Maintenance | actively maintained — 67 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 305,692/month — #7,792 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ormar-0.26.0-py3-none-any.whl
Keywords: orm, sqlalchemy, fastapi, pydantic, databases, async, alembic
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
ormar-utilsProvides Rust-accelerated implementations of…
permissive · top 15,000 on PyPI
sqlmodelSQLModel combines SQLAlchemy and Pydantic to…
permissive · top 5,000 on PyPI
fastcrudFastCRUD provides async CRUD operations and…
permissive · top 15,000 on PyPI
databasesProvides async database access for PostgreSQL,…
permissive · top 5,000 on PyPI
fastapi-users-db-sqlalchemyProvides a SQLAlchemy ORM adapter for FastAPI…
permissive · top 5,000 on PyPI
tortoise-ormTortoise ORM is an async-native…
permissive · top 15,000 on PyPI
prismaPrisma Client Python is a type-safe ORM that…
permissive · top 5,000 on PyPI
FastAPI-SQLAlchemyProvides middleware and helpers to integrate…
permissive · top 15,000 on PyPI
piccoloPiccolo is an async-first ORM and query builder…
permissive · top 15,000 on PyPI
async-factory-boyExtends factory_boy to generate test fixtures…
permissive · top 15,000 on PyPI