Expand description
Compile-time SQL query building for Rust.
This crate provides a compile-time SQL macro with schema-safe field references and automatic parameter binding.
§Quick Start
ⓘ
use sqlw::{schema, query_qmark as query};
// Define your table schema
schema!(User "users" {
ID: i64 "id",
NAME: String "name",
EMAIL: String "email",
});
// Build queries with schema-safe field references
let user_id = 42;
let query = query!(
SELECT User::NAME, User::EMAIL
FROM User::TABLE
WHERE User::ID = {user_id}
);
query.sql(); // "SELECT name, email FROM users WHERE id = ?"
query.args(); // [Int(42)]§Modules
backend- Query execution trait and row-mapping typesschema!- Table schema definitionsvalue- SQL value types and conversions
sqlw-backend (local, git)
Re-exports§
Modules§
- backend
- Query execution traits and row-mapping types.
- schema
- Table schema definitions.
- value
- SQL value types and conversions.
Macros§
- query_
numbered - Compiles a SQL query with
$1, $2placeholders. - query_
qmark - Compiles a SQL query with
?placeholders. - schema
- Defines a table schema with typed field constants and a value struct.
Structs§
- Query
- A compiled SQL query with bound parameters.
Derive Macros§
- FromRow
- Derives
FromRowfor a struct. - Into
Value - Derives [
From<T> for Value] for newtypes and enums. - TryFrom
Value Ref - Derives [
TryFrom<ValueRef>] for a single-field tuple struct (newtype).