Overview
Besu is a typesafe, async, database-agnostic SQL query builder for Rust. The query you write is the SQL that runs: there is no query planner, no identity map and no hidden second statement.
What it checks
The compiler is the first reviewer. These are errors, not runtime failures:
- a column that does not exist, or a table that is not in the query;
- comparing a text column with an integer;
- inserting into a
NOT NULLcolumn that was not provided; - selecting a
NOT NULLcolumn through aLEFT JOINand treating it asOption; UPDATEorDELETEwith noWHEREclause, unless you sayall_rows();- the wrong number of arguments to
sql!.
What it does not do
- No lazy loading. A relation is a second statement you can read, never an invisible one.
- No implicit joins. If you want a join, you write one.
- No query cache, no identity map, no change tracking. A query is a value; running it runs it.
- No schema inference at runtime. The schema is a type, generated by
#[derive(Table)], and it is the same type the migration tooling uses.
The crates
The layers are independent. besu-core knows nothing about the query API, besu knows
nothing about sqlx, and each driver knows nothing about the others. Take the whole stack, or
take the layer you need.
Driverless SQL
A dialect can render a query with no connection, which is what makes the SQL testable:
Awaiting a query built this way returns an error rather than panicking, so a driverless build can be exercised end to end.
Where to go next
- New to Besu: get started with SQLite.
- Coming from Drizzle: the surface follows Drizzle's, so read queries in order, and the comparison for where they differ.
- Interested in the internals: architecture.
