Skip to content

AllDotPy/Ryx

Repository files navigation

Ryx ORM

Ryx ORM

Django-style ORM — Python and Rust. Powered by Rust.

Python 3.10+ ryx-rs crate PyPI Downloads Version License Rust 1.83+ Discord

GitHub stars


Dual-Language ORM

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?;

Quick Install

pip install ryx                     # Python
cargo add ryx-rs ryx-macro            # Rust

Documentation

Full docs, guides, API reference: ryx.alldotpy.com

Comparison

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

Architecture

Ryx Architecture

          Python (ryx-python)        Rust (ryx-rs)
                │                         │
          PyO3 bridge ────────╗       no pyo3
                │             ║           │
          ┌─────┴─────────────║───────────┴──────┐
          │      ryx-core     ║     ryx-common   │
          └─────┬─────────────║───────────┬──────┘
                │             ║           │
          ┌─────┴─────────────║───────────┴──────┐
          │         ryx-query (SQL compiler)     │
          └───────────────────┬──────────────────┘
                              │
          ┌───────────────────┴──────────────────┐
          │          ryx-backend (sqlx)          │
          │    Postgres · MySQL · SQLite         │
          └──────────────────────────────────────┘

Performance

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

Contributing

See CONTRIBUTING.md

License

Python code: MIT · Rust code: MIT OR Apache-2.0

About

Ryx gives you the ergonomic query API of Django's ORM while running SQL execution through a compiled Rust core — giving you async-native, high-performance database access with a familiar Python interface.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors