PRQLX
Combining the query language of PRQL with the macro powers of SQLX.
PRQL is an amazing DSL for sql, but it doesn't have native support in sqlx. This crate bridges the gap by compiling prql in the rust macro itself before it's sent to sqlx (and your database). This means you can use the prql syntax with:
- All supported sqlx database
- Nice compiler errors
- Fully typed rust
Usage
use ;
async
Caveats
PRQL doesn't natively support ?
for bindings. You will have to use s"?"
for that. Rather use ${num}
for bindings.
Todos
Not all macros have been implemented. The only ones are query
and query_as
. If you would like another to be added, please file an issue (or make a PR!).
Testing/Contributing
Before running cargo test
, the database must first be setup. To do so, run cargo run --example prepare
to prepare the sqlite database. After that, you can develop as usual.