Sequelite :rocket:
Sequelite is a simple, lightweight, and fast SQLite ORM for rust.
It is built on top of rusqlite
Features
Usage
Add this to your Cargo.toml
:
[dependencies]
sequelite = "0.2"
You can find the documentation here
Example
use sequelite::prelude::*;
#[derive(Debug, Model)]
struct User {
id: Option<i32>,
#[default_value(&"Unknown name")]
name: Option<String>,
age: i32,
}
fn main() {
let mut conn = Connection::new("example.db").unwrap();
conn.register::<User>().unwrap();
conn.migrate();
conn.insert(&[
User { id: None, name: Some("John".to_string()), age: 20 },
User { id: None, name: Some("Jane".to_string()), age: 21 },
]);
let users = User::select()
.filter(User::name.eq("John"))
.exec(&conn).unwrap();
println!("{:#?}", users);
}