lume

Crates.iolume
lib.rslume
version0.13.1
created_at2025-08-15 12:11:56.458481+00
updated_at2025-12-12 19:49:50.031055+00
descriptionA simple and intuitive Query Builder inspired by Drizzle
homepage
repositoryhttps://github.com/guru901/lume
max_upload_size
id1796647
size358,437
Gurvinder Singh (Guru901)

documentation

README

Lume

A type-safe, ergonomic query builder and ORM for SQL databases, inspired by Drizzle ORM.

Crates.io Documentation License

Features

  • 🚀 Type-safe: Compile-time type checking for all database operations
  • 🎯 Ergonomic: Clean, intuitive API inspired by modern ORMs
  • Performance: Zero-cost abstractions with minimal runtime overhead
  • 🔧 Flexible: Support for MySQL, PostgreSQL, and SQLite
  • 🛡️ Safe: Parameterized queries by default to prevent SQL injection
  • 📦 Lightweight: Minimal dependencies, maximum functionality

Quick Start

Add Lume to your Cargo.toml:

[dependencies]
lume = { version = "0.12", features = ["mysql"] }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }

Basic Example

use lume::{database::Database, define_schema, filter::eq_value};

// Define your database schema
define_schema! {
    Users {
        id: Uuid [primary_key().not_null().default_random()],
        username: String [not_null()],
        email: String,
        age: i32,
        created_at: i64 [not_null()],
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Connect to your database
    let db = Database::connect("mysql://user:password@localhost/database").await?;

    // Create tables (if they don't exist)
    db.register_table::<Users>().await?;

    // Insert a new user
    db.insert(Users {
        id: None,
        username: "john_doe".to_string(),
        email: "john.doe@example.com".to_string(),
        age: 25,
        created_at: 1677721600,
    })
    .execute()
    .await?;

    // Query users
    let users = db
        .query::<Users, SelectUsers>()
        .filter(eq_value(Users::username(), "john_doe"))
        .execute()
        .await?;

    for user in users {
        let username: Option<String> = user.get(Users::username());
        println!("User: {}", username.unwrap_or_default());
    }

    Ok(())
}

Documentation

Supported Databases

Lume supports multiple database backends through feature flags:

  • MySQL: lume = { version = "0.12", features = ["mysql"] }
  • PostgreSQL: lume = { version = "0.12", features = ["postgres"] }
  • SQLite: lume = { version = "0.12", features = ["sqlite"] }

Type Mapping

Lume automatically maps Rust types to SQL types:

Rust Type SQL Type
String VARCHAR(255)
i8 TINYINT
i16 SMALLINT
i32 INT
i64 BIGINT
u8 TINYINT UNSIGNED
u16 SMALLINT UNSIGNED
u32 INT UNSIGNED
u64 BIGINT UNSIGNED
f32 FLOAT
f64 DOUBLE
bool BOOLEAN
time::OffsetDateTime DATETIME

Contributing

We are not accepting contributions at this time. We will be accepting pull requests in the future, for now you can open an issue to discuss your ideas.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for a detailed list of changes and improvements.

Commit count: 46

cargo fmt