Yara ORM¶
A fast, async Python ORM with a Rust engine — Tortoise-style models, querysets, relations and migrations for PostgreSQL, MySQL, MariaDB, SQLite, Oracle and Microsoft SQL Server.
Yara ORM is a high-performance async ORM for Python that pairs the ergonomics of a Django/Tortoise-style API — models, querysets, relations, aggregation and migrations — with a hot path (connection pooling, parameter binding, row decoding) written in compiled Rust (PyO3 + tokio). It is a drop-in-feel alternative to Tortoise ORM and async SQLAlchemy: 2–9× faster than popular pure-Python ORMs on common operations, with first-class PostgreSQL, MySQL, MariaDB and SQLite backends — plus Oracle and Microsoft SQL Server (both beta) — full type hints, and 100% test coverage.
from yara_orm import Model, YaraOrm, fields
class User(Model):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=120)
await YaraOrm.init("postgres://localhost/app") # or "mysql://…", "sqlite:///app.db"
await YaraOrm.generate_schemas()
await User.create(name="Ada")
print(await User.filter(name__icontains="ad").count())
Why Yara ORM¶
Rust engine — pooling, parameter binding and row decoding run in compiled code; the async bridge (PyO3 + tokio) keeps your event loop free.
Familiar async API — Tortoise/Django-style models, lazy chainable querysets,
Qfilters, aggregation,prefetch_related, transactions and signals.Pluggable backends — PostgreSQL, MySQL/MariaDB and SQLite, plus beta Oracle and Microsoft SQL Server backends, selected by URL; adding a database is one Rust trait plus one Python dialect.
Migrations — operation-based, auto-generated and backend-portable (
makemigrations/upgrade/downgrade).Quality — fully typed, linted (ruff + ty) and 100% test coverage.
Fast — fastest or tied against eight other Python ORMs (Tortoise, SQLAlchemy, Pony, Django, Peewee, SQLObject, Ormar, Piccolo) on common operations. See Performance.
Installation¶
Prebuilt wheels are published for Linux, macOS and Windows on CPython 3.9–3.14, so installation needs no Rust toolchain. See Installation.
Explore the docs¶
- Quick start — your first models, queries and relations in a few minutes.
- Models & fields — define models, field types, enums, comments.
- Querying — lazy querysets, lookups,
Qobjects, projections. - Relations — FK, one-to-one, many-to-many and prefetch.
- Aggregation —
Count/Sum/Avg,annotateandgroup_by. - Migrations — backend-portable, auto-generated schema migrations.
How it compares¶
Yara ORM is built for teams who want the developer experience of Tortoise ORM or the async query style of SQLAlchemy 2.0, but with materially lower per-query overhead because binding and decoding happen in Rust rather than Python. If you are searching for a fast async Python ORM for PostgreSQL or MySQL (or a lightweight one for SQLite), Yara ORM is designed to be a direct, fully-typed replacement.
License¶
Yara ORM is released under the MIT License.