Add the diesel crate to your Cargo.toml and run diesel setup to initialize your database.
[dependencies]
diesel = { version = "2.2.10", features = ["sqlite", "r2d2"] }
- Add the dependency to your
Cargo.tomlfile. - Run
cargo install diesel_cli --no-default-features --features sqliteto install the CLI. - Execute
diesel setupto create the database and migrations directory. - Define your schema in
src/schema.rsusingdiesel::table!. - Implement your models in
src/lib.rsusing#[derive(Queryable, Insertable)]. - Run
cargo runto execute your application.