Skip to content

Yara ORM

A fast, async Python ORM with a Rust engine — Tortoise-style models, querysets, relations and migrations for PostgreSQL and SQLite.

CI PyPI Python License: MIT

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 and SQLite backends, 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 "sqlite:///app.db"
await YaraOrm.generate_schemas()

await User.create(name="Ada")
print(await User.filter(name__icontains="ad").count())

Install Yara ORM Quick start

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, Q filters, aggregation, prefetch_related, transactions and signals.
  • 🗄 Pluggable backendsPostgreSQL and SQLite today, 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.
  • 🚀 Fast2–9× faster than Tortoise ORM, async SQLAlchemy and Pony on common operations. See Performance.

Installation

pip install yara-orm

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, Q objects, projections.
  • Relations — FK, one-to-one, many-to-many and prefetch.
  • AggregationCount/Sum/Avg, annotate and group_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 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.