# ormar-orm/ormar

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/ormar-orm-ormar).**

1,805 stars · 97 forks · Python · MIT

## Links

- GitHub: https://github.com/ormar-orm/ormar
- Homepage: https://collerek.github.io/ormar/
- awesome-repositories: https://awesome-repositories.com/repository/ormar-orm-ormar.md

## Topics

`alembic` `async-orm` `databases` `fastapi` `orm` `pydantic` `python-orm` `sqlalchemy`

## Description

Ormar is an asynchronous object-relational mapper for Python that integrates database persistence with data validation. It functions as a bridge between relational database management and application-level data structures, allowing developers to define database schemas that serve simultaneously as validation models.

The project distinguishes itself by using validation classes to enforce schema integrity, ensuring that all persisted records conform to defined types and structures. It supports complex relational associations, including one-to-many and many-to-many relationships, and provides event-driven lifecycle hooks that trigger custom logic during record state changes to maintain data consistency.

The library covers a broad range of database management capabilities, including non-blocking query execution and automated schema migration tools. It utilizes a low-level query builder to translate object methods into structured database operations, while providing command-line utilities to synchronize physical database versions with application code across different environments.

## Tags

### Data & Databases

- [Async Python ORMs with Relations](https://awesome-repositories.com/f/data-databases/relationship-modeling/one-to-many-relationship-models/async-python-orms-with-relations.md) — Provides an asynchronous object-relational mapper that integrates Pydantic validation with web framework compatibility.
- [Object-Relational Mapping Associations](https://awesome-repositories.com/f/data-databases/object-relational-mapping-associations.md) — Defines complex relational associations and foreign key constraints through declarative class-level attributes.
- [Relational Data Modeling](https://awesome-repositories.com/f/data-databases/relational-data-modeling.md) — Organizes data into structured tables with defined one-to-many and many-to-many relationships. ([source](https://github.com/ormar-orm/ormar/blob/master/README.md))
- [Asynchronous Database Drivers](https://awesome-repositories.com/f/data-databases/asynchronous-database-drivers.md) — Provides non-blocking database connectivity by leveraging asynchronous drivers to maintain high concurrency.
- [Database Lifecycle Hooks](https://awesome-repositories.com/f/data-databases/database-lifecycle-hooks.md) — Triggers custom logic automatically before or after database operations to ensure data consistency. ([source](https://github.com/ormar-orm/ormar/blob/master/README.md))
- [Database Schema Migrations](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/database-management/database-schema-migrations.md) — Applies versioned updates to database schemas to maintain structural compatibility with application code.
- [Database Migration Management](https://awesome-repositories.com/f/data-databases/database-migration-management.md) — Coordinates schema changes and versioning across development, testing, and production environments. ([source](https://github.com/ormar-orm/ormar/blob/master/README.md))
- [Many-to-Many Associations](https://awesome-repositories.com/f/data-databases/many-to-many-associations.md) — Manages complex entity associations and integrity across related database tables.
- [Relational Database Integrations](https://awesome-repositories.com/f/data-databases/relational-database-integrations.md) — Provides a toolkit for managing complex table associations and schema migrations in asynchronous applications.
- [Query Builders](https://awesome-repositories.com/f/data-databases/sql-query-generation/query-builders.md) — Translates high-level object methods into optimized SQL statements using a low-level query builder.

### Software Engineering & Architecture

- [Pydantic Schema Validation](https://awesome-repositories.com/f/software-engineering-architecture/data-validation-schemas/pydantic-schema-validation.md) — Enforces strict schema integrity and type validation using Pydantic models for all persisted records.
- [Asynchronous Database Access](https://awesome-repositories.com/f/software-engineering-architecture/asynchronous-database-access.md) — Performs non-blocking database operations to maintain high performance during heavy data processing.
- [Asynchronous Operation Execution](https://awesome-repositories.com/f/software-engineering-architecture/asynchronous-operation-execution.md) — Enables non-blocking database operations to retrieve and modify records without stalling the main application thread. ([source](https://github.com/ormar-orm/ormar#readme))
- [Database Schema Migrations](https://awesome-repositories.com/f/software-engineering-architecture/data-migrators/database-schema-migrations.md) — Automates database schema evolution and versioning to keep physical structures synchronized with application code.
- [Lifecycle Event Hooks](https://awesome-repositories.com/f/software-engineering-architecture/lifecycle-event-hooks.md) — Executes custom logic at specific stages of the database record lifecycle to maintain data integrity.
- [Unified Data Modeling](https://awesome-repositories.com/f/software-engineering-architecture/unified-data-modeling.md) — Defines database schemas that serve as both persistence layers and validation models for web application endpoints. ([source](https://github.com/ormar-orm/ormar/blob/master/README.md))
