| Crates.io | drizzle |
| lib.rs | drizzle |
| version | 0.1.4 |
| created_at | 2025-11-27 01:03:44.210969+00 |
| updated_at | 2026-01-24 07:10:57.256686+00 |
| description | A type-safe SQL query builder for Rust |
| homepage | |
| repository | https://github.com/themixednuts/drizzle-rs |
| max_upload_size | |
| id | 1952836 |
| size | 1,012,229 |
A type-safe SQL query builder / ORM-ish layer for Rust, inspired by Drizzle ORM.
[!WARNING] This project is still evolving. Expect breaking changes.
#[SQLiteTable], #[PostgresTable],
#[derive(SQLiteSchema)], etc.drizzle binary.Pick a database driver feature (drivers imply the corresponding dialect module):
[dependencies]
drizzle = { version = "0.1.3", features = ["rusqlite"] } # or: libsql / turso / postgres-sync / tokio-postgres
Install the drizzle binary with the driver(s) you want:
# SQLite (sync)
cargo install drizzle-cli --locked --features rusqlite
# PostgreSQL (sync)
cargo install drizzle-cli --locked --features postgres-sync
# Turso / LibSQL (async)
cargo install drizzle-cli --locked --features turso
use drizzle::core::expr::eq;
use drizzle::sqlite::prelude::*;
use drizzle::sqlite::rusqlite::Drizzle;
#[SQLiteTable]
pub struct Users {
#[column(primary)]
pub id: i64,
pub name: String,
pub age: i64,
}
#[derive(SQLiteSchema)]
pub struct Schema {
pub users: Users,
}
fn main() -> drizzle::Result<()> {
let conn = rusqlite::Connection::open_in_memory()?;
let (db, Schema { users }) = Drizzle::new(conn, Schema::new());
// Note: create statements are intentionally not IF NOT EXISTS (to stay compatible with migrations).
// Use this only for a fresh DB (or rely on migrations).
db.create()?;
db.insert(users)
.values([InsertUsers::new("Alex Smith", 26i64)])
.execute()?;
let row: SelectUsers = db
.select(())
.from(users)
.r#where(eq(users.name, "Alex Smith"))
.get()?;
println!("user: {row:?}");
Ok(())
}
For more complete examples (including JOIN mapping via
#[derive(SQLiteFromRow)]), see examples/ and tests/.
drizzle init -d sqlite # dialects: sqlite, turso, postgresql, mysql, singlestore
drizzle generate # generate migrations from schema changes
drizzle migrate # apply pending migrations
| Feature | Enables |
|---|---|
sqlite |
SQLite dialect module re-exports (drizzle::sqlite) |
postgres |
PostgreSQL dialect module re-exports (drizzle::postgres) |
rusqlite |
SQLite sync driver (drizzle::sqlite::rusqlite) |
libsql |
SQLite async driver (drizzle::sqlite::libsql) |
turso |
Turso/LibSQL async driver (drizzle::sqlite::turso) |
postgres-sync |
PostgreSQL sync driver (drizzle::postgres::sync) |
tokio-postgres |
PostgreSQL async driver (drizzle::postgres::tokio) |
uuid |
UUID support |
serde |
JSON support (serde/serde_json integration) |
chrono / cidr / geo-types / bit-vec |
Optional PostgreSQL types |
arrayvec |
Fixed-capacity strings/arrays support |
cargo build --all-featurescargo test --features "rusqlite,uuid"just test-pgcargo clippy --all-features -- -D warningsMore commands and repo details live in CLAUDE.md.
MIT — see LICENSE.