Besu
A typesafe, async, database-agnostic SQL query builder for Rust.
Besu is a typesafe, async, database-agnostic SQL query builder for Rust. It is not an ORM: every query you write maps onto exactly the SQL you would have written by hand, and the compiler checks the parts it can see — column names, column types, nullability, which tables are in the query, and whether a bulk write was intentional.
The structure follows Drizzle ORM, because that is where the design comes from. If you know Drizzle, the pages here will feel familiar; if you do not, read them in order.
Fundamentals
- Overview — what Besu is, and what it deliberately is not
- Get started with SQLite
- Get started with PostgreSQL
- Get started with MySQL
- Schema declaration —
#[derive(Table)]and every attribute - Relations —
has_many, and loading children without an N+1 - Connect — a driver, a pool, a database
- Queries and CRUD — the shape of every statement
- Migrations — the schema IR,
push,generate,migrate
Manage schema
- Column types: PostgreSQL · MySQL · SQLite
- Indexes and constraints
- Views
- Sequences — PostgreSQL
- Table schemas — PostgreSQL
- Row-level security — PostgreSQL
- Extensions — PostgreSQL
- Custom types
Access your data
- Select · Insert · Update · Delete
- Filter and conditional operators
- Joins
- Aliases
- The
sql!operator - Query utilities
- SQL comments
- Set operations
- Subqueries
Migrations
- Migrations overview
besu generate·besu migrate·besu push·besu pullbesu studio- Custom migrations
- Configuration
Advanced
Reference
- Performance — what a query costs, with numbers
- Architecture — the crate graph and how a query becomes SQL
- Writing a driver —
Dialect,Driver,SchemaDriver,Ddl,Decode - Comparison — Besu against Diesel, SeaORM, sqlx and Drizzle
- Roadmap — what is missing, and what it would take
How to read a page
Pages are code first: a short statement of what the thing is, an example you can paste, then the details that are easy to get wrong. Each page ends with What is checked or Gotchas — the honest part, where the compiler stops helping and what still bites.
Examples use SQLite because it needs no server. The same query code works with every driver; only the connection setup changes.
