ruprizzle 1.6.0

A schema-first ORM for Rust: typed queries, relations, and automatic migrations
Documentation

ruprizzle

Crates.io docs.rs License

A schema-first ORM for Rust: typed queries, relations, and automatic migrations.

ruprizzle is the runtime crate that you use in your application. Combine a declarative schema.ruprizzle file with the ruprizzle-cli code generator and you get a fully typed query builder, migrations, and relation include support for PostgreSQL, MySQL/MariaDB, and SQLite behind a single API. Optional native-driver feature flags (sqlite-rusqlite, postgres-tokio-postgres) and an optional metrics feature are also available.

Features

  • Generated, type-safe clients — model structs, column tokens, and the Db root are generated from your schema.
  • Drizzle-style query builder — chain .filter, .select, .order, .include, .page, and more, and see the SQL.
  • Relations — one-to-one, one-to-many, and nested include with per-relation limits.
  • Migrations — diff your schema against the live database and generate up.sql / down.sql.
  • Raw SQL, safely — raw! macro for fragments that are bound, not interpolated.
  • Transactions — explicit Tx::begin / commit / rollback and isolation-level helpers.
  • Multi-backend — the same code runs on PostgreSQL, MySQL/MariaDB, and SQLite.

Example

use ruprizzle::{Column, InsertQuery, SelectQuery};
use generated_client::{Db, User, EMAIL};

let db = Db::connect("sqlite://app.db").await?;

let user = InsertQuery::<User>::new(db.raw_pool())
    .set(EMAIL, "hello@example.com")
    .exec()
    .await?;

let users = SelectQuery::<User>::new(db.raw_pool())
    .filter(EMAIL.contains("@example.com"))
    .fetch_all()
    .await?;

For a full getting-started guide, see the project homepage.

Keywords

orm, sql, database, postgres, sqlite