belchior / sql_query_builder

Write SQL queries in a simple and composable way
https://crates.io/crates/sql_query_builder
MIT License
54 stars 5 forks source link

Adds SQLite syntax #8

Closed belchior closed 10 months ago

belchior commented 10 months ago

Breaking changes

This PR setup the minimum rust version to 1.62.0

New features

Adds SQLite syntax support, you can enable it using

# Cargo.toml

sql_query_builder = { version = "2.x.x", features = ["sqlite"] }

The current release adds suppport for the following commands

Example

use sql_query_builder as sql;

let update_orders = sql::Update::new()
  .update("orders")
  .set("items = $1")
  .where_clause("login = $2");

let insert_address = sql::Insert::new()
  .insert_into("address(login, contry, postcard)")
  .values("($2, 'Bar', '01234000')");

let query = sql::Transaction::new()
  .begin("")
  .update(update_orders)
  .insert(insert_address)
  .end("")
  .to_string();

println!("{query}");
-- indented for readability
BEGIN;
UPDATE orders SET items = $1 WHERE login = $2;
INSERT INTO address(login, contry, postcard) VALUES ($2, 'BR', '01234000');
END;