Ryx for Rust
Ryx is a Django-style ORM for Rust. Async-native, with zero Python dependencies.
use ryx_rs::{model, ObjectsManager};
#[model]
struct Post {
#[field(pk)]
id: i64,
title: String,
views: i64,
active: bool,
}
let posts = ObjectsManager::<Post>::new()
.filter("active", true)
.order_by("-views")
.all().await?;
Many older snippets use a convenience helper named Post::objects(). The macro
does not need that helper; the canonical entry point is
ObjectsManager::<Post>::new(). If you prefer the shorter style, define it once:
impl Post {
fn objects() -> ObjectsManager<Self> {
ObjectsManager::new()
}
}
Cratesโ
| Crate | Description |
|---|---|
ryx-rs | Core ORM: models, QuerySet, migrations, caching |
ryx-macro | Proc macros: #[model], #[field], #[table], #[relation] |
Quick Comparisonโ
| Feature | Python (ryx) | Rust (ryx-rs) |
|---|---|---|
| Model definition | Class + Fields | #[model] struct |
| QuerySet | Post.objects | ObjectsManager::<Post>::new() or a user-defined Post::objects() helper |
| Filtering | .filter(active=True) | .filter("active", true) |
| Q objects | Q(active=True) | Q(...) | Q::or(Q::new(...), ...) |
| Create | .create(title="...") | .create().set("title", "...").save() |
| Migrations | MigrationRunner([Post]) | MigrationRunner::new().model::<Post>() |
| Relations | ForeignKey(Author) | #[relation(model = "Author", ...)] |
| CLI | python -m ryx migrate | ryx migrate |
| File-based migrations | .py files + Autodetector | .yaml files + Autodetector |
| Multi-DB routing | Meta.database + model= | #[database("alias")] |
Next Stepsโ
- Installation โ Add Ryx to your Cargo.toml
- Quick Start โ Your first query in 5 minutes