Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

Ryx ORM

Ryx ORM

Django-style ORM for Python and Rust. Powered by a shared Rust SQL engine.

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

Quick Install

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

Documentation

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

Feature Map

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

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) 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

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

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.