// the find
diesel-rs/diesel
A safe, extensible ORM and Query Builder for Rust
Diesel is a compile-time query builder and ORM for Rust that catches type mismatches and schema errors before your code runs. It supports PostgreSQL, MySQL, and SQLite. If you're writing a Rust service that talks to a relational database and you want the compiler to catch mistakes instead of your production logs, this is the standard choice.
The type system integration is the real differentiator — column type mismatches, joining on the wrong table, selecting a nullable column into a non-Option field, all compile errors rather than runtime panics. The schema macro generates a typed DSL from your actual schema, so drift between your types and the database is caught immediately. The query builder composes well: you can build a base query and conditionally extend it without resorting to string concatenation or losing type safety. Benchmark suite includes comparisons against sqlx, SeaORM, tokio-postgres, and raw drivers, so you can see exactly what you're trading for the abstraction.
No async support in the main crate — diesel-async exists as a separate crate maintained separately, which means you're dealing with two projects, potential version skew, and a thinner ecosystem. The learning curve is steep: the type-level machinery that makes it safe also means error messages can be genuinely impenetrable when you get something wrong, and the derive macros have enough gotchas that new users regularly hit confusing walls. Complex queries with many joins or dynamic conditions can produce types so nested they become unworkable without boxing, which partially defeats the point. MySQL support is a second-class citizen — several Postgres-specific features (RETURNING, COPY, ranges, arrays) simply don't exist for MySQL, and the feature gap is documented but not small.