Is it possible to create a new database in Rust using Diesel? I can't find anything in the documentation. I am specifically interested in SQLite.
Is it possible to create a new database in Rust using Diesel? I can't find anything in the documentation. I am specifically interested in SQLite.
TBH, I didn't really search in the documentation but, on the Cargo.toml side, you need :
[dependencies]
diesel = { version = "1.4.3", features = ["sqlite"] }
Inside you .env file, you can specify the path to the database file like :
DATABASE_URL=mydb.sqlite3
If you follow the "Getting Started" guide, then, you just need to use SqliteConnection instead of PgConnection :
use diesel::sqlite::SqliteConnection;
// ...
pub fn establish_connection() -> SqliteConnection {
// ...
}
What you‘re looking for is not the diesel lib, but its corresponding CLI tool diesel_cli. See http://diesel.rs/guides/getting-started/ .