Skip to main content

Crate drizzle

Crate drizzle 

Source
Expand description

§Drizzle for Rust

A type-safe SQL query builder for Rust, supporting SQLite and PostgreSQL.

§Quick Start

use drizzle::sqlite::prelude::*;
use drizzle::sqlite::rusqlite::Drizzle;

#[SQLiteTable(name = "Users")]
struct User {
    #[column(primary)]
    id: i32,
    name: String,
    email: Option<String>,
}

#[derive(SQLiteSchema)]
struct Schema {
    user: User,
}

let conn = rusqlite::Connection::open_in_memory()?;
let (db, Schema { user, .. }) = Drizzle::new(conn, Schema::new());

db.create()?;
db.insert(user)
    .values([InsertUser::new("John Doe").with_email("john@example.com")])
    .execute()?;

let users: Vec<SelectUser> = db.select(()).from(user).all()?;

§Database Support

DatabaseDriverFeature FlagStatus
SQLiterusqliterusqlite
SQLitelibsqllibsql
SQLitetursoturso
PostgreSQLpostgrespostgres-sync
PostgreSQLtokio-postgrestokio-postgres

For schema declarations, import the database prelude:

  • drizzle::sqlite::prelude::*
  • drizzle::postgres::prelude::*

For expressions and conditions, import from drizzle::core::expr.

Modules§

core
Core traits, SQL types, and expressions shared across drivers.
ddl
DDL types and schema definitions.
error
Error types.
migrations
Migration helpers and schema snapshots.

Macros§

drizzle_prepare_impl
sql
SQL template macro. A procedural macro for building SQL queries with embedded expressions.

Enums§

Dialect
Database dialect enum. SQL dialect for database-specific behavior

Type Aliases§

Result
Result type for drizzle operations. Result type for database operations