Rust ORM comparison
Rent vs SQLx
SQLx is a Rust SQL toolkit, not an ORM. You write SQL by hand and its macros check each query against a database or an offline cache at compile time. It is excellent when you want SQL in your code and full control over every statement.
Rent uses SQLx as its driver layer and adds what SQLx deliberately leaves out: a schema you can review, a generated client so you do not hand-write queries for ordinary reads and writes, a migration planner that diffs the schema against the catalog, and row policies. Raw SQL remains available as an explicit escape hatch.
Side by side
| Aspect | Rent (Rust) | SQLx (Rust) |
|---|---|---|
| Schema source | One central RSL document is the source of truth. The Rust client and the database catalog are both derived from it. | No schema. The database is the source of truth and queries are checked against it. |
| Queries | Generated builders for CRUD, filters, relationships, transactions, and pagination, plus raw SQL when you want it. | Hand-written SQL with compile-time checked macros. |
| Migrations | Rent diffs the RSL schema against the live catalog, classifies every operation as safe, review, or destructive, writes append-only SQL, and seals it with checksums in rent.sum. | Hand-written SQL migration files applied in order by sqlx migrate. |
| Authorization | Row policies, tenant scoping, hooks, and interceptors are part of the generated client and apply to reads, writes, and relationship endpoints. | None; authorization lives in your SQL and application code. |
| PostgreSQL extensions | Typed packages for pgvector, PostGIS, pgmq, pg_cron, pg_net, TimescaleDB, pg_search, pg_trgm, citext, pgcrypto, uuid-ossp, pg_jsonschema, pg_partman, and pgAudit, declared in the schema and checked before migration. | Extensions are used through raw SQL and manual type mapping. |
| Databases | PostgreSQL first, with MySQL, MariaDB, and SQLite on the same generated client. | PostgreSQL, MySQL, MariaDB, and SQLite. |
Choose Rent when
- You want a schema-first workflow with generated, typed builders.
- You want migrations derived from the schema and classified for safety.
- You want policies and tenancy enforced below the application.
Choose SQLx when
- You prefer writing every query as SQL.
- You want the smallest possible abstraction over the driver.