IMPORTANT - 0.0.x versions will be experimental and probably break APIs in each release.
sqlb is (will be) a simple and expressive SQLBuilder for Rust.
NOTE: SQL Builders are typically not used directly by application business logic, but rather to be wrapped in some Application Data Access Layer (e.g., DAOs or MACs - Model Access Controller -). In fact, even when using ORMs, it is often a good code design to wrap those access via some data access layers.
Goals for first 0.1.x releases:
```rust
pub struct Todo { pub id: i64, pub title: String, }
pub struct TodoPatch {
pub title: Option
let patchdata = TodoPatch { title: Some("Hello Title".tostring()) };
// INSERT - Insert a new Todo from a Partial todo let sb = sqlb::insert().table("todo").data(patchdata.fields()); let sb = sb.returning(&["id", "title"]); let (id, title) = sb.fetchone::<(i64, String), _>(&dbpool).await?;
// SELECT - Get all todos
let sb = sqlb::select().table("todo").columns(&["id", "title"]).orderby("!id");
let todos: Vec
0.0.7
- sqlb::insert().table("todo")
(in 0.0.7) rather than sqlb::insert("toto")
(<=0.0.6) (for all SqlBuilders)Start a PostgreSQL
```sh
docker run --rm --name pg -p 5432:5432 -e POSTGRES_PASSWORD=welcome postgres:14
docker exec -it -u postgres pg psql
--test-threads=1
to avoid database access conflictscargo test -- --test-threads=1
cargo watch -q -c -x 'test --test testsbinsert -- --test-threads=1' ```