Django-style ORM for Python and Rust. Powered by a shared Rust SQL engine.
import ryx
from ryx import Model, BooleanField, CharField, IntField, Q
class Post(Model):
title = CharField(max_length=200)
views = IntField(default=0)
active = BooleanField(default=True)
await ryx.setup("postgres://user:pass@localhost/mydb")
posts = await Post.objects.filter(Q(active=True) | Q(views__gte=1000))use ryx_rs::model;
use ryx_rs::{ObjectsManager, Q};
#[model]
struct Post {
#[field(pk)] id: i64,
title: String,
views: i64,
active: bool,
}
let posts = ObjectsManager::<Post>::new()
.all()
.filter(Q::or(Q::new("active", true), Q::new("views__gte", 1000)))
.all().await?;pip install ryx # Python
cargo add ryx-rs ryx-macro # RustFull docs, guides, API reference: ryx.alldotpy.com
| Area | Python API | Rust API |
|---|---|---|
| Models | Model, Field, Meta, hooks |
#[model], Model, FromRow, metadata |
| Fields | Auto, integer, numeric, text, date/time, JSON, array, binary, relation fields | Macro-derived field metadata |
| Queries | Lazy async QuerySet, Q, lookups, transforms, joins, values, annotations |
QuerySet<T>, Q, lookups, values, annotations |
| CRUD | create, save, get, first, count, update, delete, refresh_from_db |
InsertBuilder, all, get, first, count, update, delete |
| Bulk/streaming | bulk_create, bulk_update, bulk_delete, chunked/keyset stream |
streaming chunks through QueryStream |
| Transactions | async with transaction() with savepoints |
`transaction( |
| Migrations | autodetect, DDL generation, runner, CLI | state diffing, DDL generation, runner |
| Multi-db | aliases, .using(), Meta.database, router, env/config auto-init |
aliases, .using(), config init |
| PostgreSQL schemas | .schema(), schema-aware migrations |
.schema() |
| Caching | MemoryCache, QuerySet.cache(), invalidation helpers |
cache backend and cached queryset |
| Signals/hooks | pre/post save/delete/update and model hooks | not part of Rust surface |
| Raw SQL | raw fetch/execute and parameterized helpers | backend/query crates |
| Diesel | SeaORM | Ryx (Rust) | |
|---|---|---|---|
| API style | Schema-first | Verbose builders | Django-like |
| Q objects (OR/AND/NOT) | ❌ | ❌ | ✅ |
| Lookups | Basic | Basic | 30+ |
| select_related | ❌ | ✅ (Eager) | Rust API; Python currently uses explicit .join() |
| Migrations | Diesel CLI | sea-orm-cli | Built-in |
| PostgreSQL schemas | ❌ | ❌ | ✅ |
| Backends | PG · MySQL · SQLite | PG · MySQL · SQLite | PG · MySQL · SQLite |
Python (ryx-python) Rust (ryx-rs)
│ │
PyO3 bridge ────────╗ no pyo3
│ ║ │
┌─────┴─────────────║───────────┴──────┐
│ ryx-core ║ ryx-common │
└─────┬─────────────║───────────┬──────┘
│ ║ │
┌─────┴─────────────║───────────┴──────┐
│ ryx-query (SQL compiler) │
└───────────────────┬──────────────────┘
│
┌───────────────────┴──────────────────┐
│ ryx-backend (sqlx) │
│ Postgres · MySQL · SQLite │
└──────────────────────────────────────┘
1 000 rows on SQLite (lower is better):
| Operation | Ryx ORM | SQLAlchemy ORM | SQLAlchemy Core |
|---|---|---|---|
| bulk_create | 0.0074 s | 0.1696 s | 0.0022 s |
| bulk_update | 0.0023 s | 0.0018 s | 0.0010 s |
| bulk_delete | 0.0005 s | 0.0012 s | 0.0009 s |
| filter + order + limit | 0.0009 s | 0.0019 s | 0.0008 s |
| aggregate | 0.0002 s | 0.0015 s | 0.0005 s |
See CONTRIBUTING.md
Python code: MIT · Rust code: MIT OR Apache-2.0