Skip to content

Jomy10/modelite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modelite

Crates.io License Crates.io Version

Modelite defines traits and macros to generate SQL queries as strings, or to be used with sqlx (with feature "sqlx", enabled by default).

#[derive(Model)]
struct Person {
    name: String,
    age: u32,
    nickname: Option<String>
}

#[tokio::main]
async fn main() {
    let pool = SqlitePool::connect("sqlite::memory:").await.unwrap();
    
    Person::create_table().execute(&pool);
    Person::insert_bulk(&pool, &[Person {
        name: String::from("Steven"),
        age: 35,
        nickname: None
    }]).execute_all(&pool);
}

About

Generate sql definitions and queries in SQLite for a struct in Rust

Resources

License

Stars

Watchers

Forks

Contributors

Languages