--- id: ormar version: "0.26.0" license: MIT license_treatment: permissive maintenance: active --- # ormar — An async ORM with fastapi in mind and pydantic validation. License: permissive · Maintenance: active · Downloads: 305.7K/mo ## 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 above — 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 pip install ormar uv add ormar 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_current - Install friction: low - Maintenance: active - Downloads: 305.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags async ORM Python, FastAPI database ORM, pydantic ORM, async SQLAlchemy wrapper, single model ORM validation, async-orm, fastapi-integration, pydantic-native [View on SkillFed](https://skillfed.io/packages/ormar) · [View on PyPI](https://pypi.org/project/ormar/)