Example
# use ;
# use fs;
// Import the table names from the schema we just created.
use *;
When to use
Use this library if you want to fearlessly query and migrate your SQLite database with a Rusty API build on an encoding of your schema in types.
Here are some errors that rust-query can prevent at compile-time:
- Column type errors.
- Foreign key violations on insert/update.
- Mismatches in number of returned rows (zero, one or multiple).
- Use of undefined columns.
- SQL syntax errors.
Some other errors cannot be prevented at compile-time, but they can
be turned into Result types so that the user is aware of them:
- Unique constraint errors.
- Foreign key violations on delete.
Next to those features, rust-query also helps writing complex queries:
- Reuse part of your query in another query by extracting it into a Rust function. Query types are kept simple so that the required function signature is easy to write.
- Aggregates that always return a single row make it easier to reason about queries.
- Automatic decorrelation of correlated sub-queries makes it possible to run those on SQLite.
When not to use
Do not use rust-query if you want a zero-cost abstraction.
The focus of this project is on bringing errors to compile-time and
generally making transactions easier to write.
Do not use rust-query migrations if you plan to keep those migrations around for a long time.
Currently rust-query generates quite a bit of code for every version of your schema and migrations
may need to be updated to work with a new breaking version of rust-query.
Improving compatiblity with migrations managed by other tools is on the roadmap.
Note that this project is still in relatively early stages. There might be bugs to catch, so if you are worried about that, then don't use this yet.
Roadmap
The current focus is on making the library more accessible and more generally useful. Funded by NLnet!