IMPORTANT - sqlb 0.5.x has a TOTALLY NEW STRATEGY and IMPLEMENTATION

The result is a bit more verbose, but it takes full advantage of sea-query:

So, sqlb just adds the missing mile:

And more to come.

See Rust web-app production code blueprint on rust10x.com for an example of how this is used in a production code envornement

Quick Example

```rust // sqlb::Fields

[derive(sqlb::Fields, Debug, Default)]

struct TodoForCreate { title: String, done: Option, // if None, not set, so db default (false) #[field(name = "description")] desc: Option, // if None, not set, so db default (false) } ```

| Function/Method | Returns | |--------------------------------|----------------------------------------------------------| | TodoForCreate::field_names() | ["title", "done", "description"] | | TodoForCreate::field_idens() | Vec<sea_query::DynIden> (for sea-query select) | | todo_object.all_fields() | Fields object allowing the following | | fields.zip() | (Vec<DynIden>, Vec<SimpleExpr>) for sea-query insert | | fields.unzip() | Iterator of (DynIden, SimpleExpr) for sea-query update | | fields.push(Field::new(...)) | To add dynamic name/value to be inserted/updated |

Full examples

See alpha_v050/examples

sh cargo run -p example-tokio-postgres cargo run -p example-sqlx-postgres

Notes for other databases

Note: Currently, sqlb is completely DB-unaware, meaning that the examples provided above could be adapted to MySQL or SQLite by simply changing the DB Driver and Sea-Query binding dependency. For reference, see sea-query examples.

Changelog

! breaking change, ^ enhancement, + addition, - fix.

For sqlb Dev

Start a PostgreSQL

```sh

In terminal 1 - start postges

docker run --rm --name pg -p 5432:5432 -e POSTGRES_PASSWORD=welcome postgres:15

In terminal 2 - (optional) launch psql on the Postgres instance above

docker exec -it -u postgres pg psql

In terminal 3 -

cargo test

or watch a particular test target

cargo watch -q -c -x 'test --test testsbinsert ```


sqlb github repo