Django-style ORM — Python and Rust. Powered by Rust.
import ryx
from ryx import Model, CharField, 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;
#[model]
struct Post {
#[field(pk)] id: i64,
title: String,
views: i64,
active: bool,
}
let posts = Post::objects()
.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
| Diesel | SeaORM | Ryx (Rust) | |
|---|---|---|---|
| API style | Schema-first | Verbose builders | Django-like |
| Q objects (OR/AND/NOT) | ❌ | ❌ | ✅ |
| Lookups | Basic | Basic | 30+ |
| select_related | ❌ | ✅ (Eager) | ✅ |
| Migrations | Diesel CLI | sea-orm-cli | Built-in |
| 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