Crates.io | rsyesql |
lib.rs | rsyesql |
version | 0.3.1 |
source | src |
created_at | 2020-04-15 08:06:40.657147 |
updated_at | 2020-04-15 08:35:14.7444 |
description | Transform SQL queries text to Rust strings. |
homepage | |
repository | https://github.com/fanatid/rsyesql |
max_upload_size | |
id | 230409 |
size | 10,573 |
Inspired by Yesql, see rational section there for more info.
queries.sql
:
-- name: select
SELECT * FROM users;
-- name: delete
DELETE FROM users WHERE id = $1;
In Rust
code:
let queries = rsyesql::parse(include_str!("./queries.sql"));
println!("{}", queries.get("select").unwrap()); // SELECT * FROM users;
println!("{}", queries.get("delete").unwrap()); // DELETE FROM users WHERE id = $1;