skillfed

ormar

An async ORM with fastapi in mind and pydantic validation.

ormar v0.26.0 305.7K downloads/30d#7,792 on PyPI1,804
Permissive license MIT Active released

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 ormar

uv

uv add ormar

poetry

poetry add ormar

Installing 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

Development Status :: 4 - BetaEnvironment :: Web EnvironmentFramework :: AsyncIOIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTP

Tags

async ORM PythonFastAPI database ORMpydantic ORMasync SQLAlchemy wrappersingle model ORM validation
async-ormfastapi-integrationpydantic-native

More WWW/HTTP packages