January 2019
Intermediate to advanced
520 pages
14h 32m
English
To create a connection, we extract the path to a database. Since we are using the SQLite database, in contrast to the previous examples, we don't expect a URL, but instead a path to a database file. That's why we use the test.db filename instead of a URL:
let path = matches.value_of("database") .unwrap_or("test.db"); let manager = ConnectionManager::<SqliteConnection>::new(path); let pool = r2d2::Pool::new(manager)?;
r2d2::Pool requires a ConnectionManager instance to establish connections with a database, and we can provide SqliteConnection as an associated type to use the SQLite database. We provide a path to a database extracted from command-line arguments. Now let's look at how to use a generated DSL to interact ...
Read now
Unlock full access