Why not sqlx, SeaORM or Diesel?
When I started Rust, my first project needed a database, so I looked for an ORM. I quickly found that usage was rather raw, a bit like SQLAlchemy in Python. Coming from Django, I believed developers shouldn't have to be SQL experts to build an application. Django does that abstraction wonderfully.
I tried several ORMs: plenty of usage simplifications, but joins, table definitions and worst of all migrations were full of commands to write. So I thought: let's take Django's mindset, bring it to Rust, and get back that ease and simplicity of using an ORM.
That's how Rango was born: Rust + Django = Rango.
Those are good tools, but they all ask you to know, or write, a fair amount of SQL. Here is what each one asks of you:
| Tool | What you write | Notes |
|---|---|---|
| Rango | Structs. That is it. | Migrations, joins and constraints are generated. Async, PostgreSQL / SQLite / MySQL & MariaDB. Young project. |
| Diesel | A table! schema, SQL migrations | Strong typing, large and mature. Sync-first core (async via diesel-async). |
| sqlx | All the SQL, migrations included | Not an ORM, and great at what it does. Rango is built on top of it. |
| SeaORM | Entity + ActiveModel, migrations in Rust | Async and active. Entity-first schema sync exists but is newer. |
| Butane | Structs | Same starting idea: migrations generated from models. Describes itself as experimental; PostgreSQL and SQLite; async since 0.8; queries through a query! macro. |
Rango is not the only one to generate migrations. Its goal is to be the simplest: the whole Django experience, not just the migrations. Relations, subqueries, transactions, bulk operations, hooks, constraints and backups all work without writing SQL, async from the ground up, and the same code runs on three databases.
And where Django fell short:
ON DELETE CASCADEis done by the database, not by deleting row by row in application code.Option<T>is the one concept for nullable, instead ofnull=Trueandblank=True.- Queries are typed, not strings.