aboutsummaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-08-23 16:56:02 +0100
committerAkshay <[email protected]>2020-08-23 16:56:02 +0100
commit311b48924d2e20deb8733a2b94a531f55a83e205 (patch)
treeb77895990e09ae425e710dfaa37b6ac338306dae /src/db.rs
parente16743598ccdaae9709034a7215c35ccfe2a49fa (diff)
add logging
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/db.rs b/src/db.rs
index a5c0f85..4025e12 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -1,11 +1,14 @@
1use anyhow::Result; 1use anyhow::Result;
2use log::{debug, info};
2use rusqlite::{Connection, OpenFlags, NO_PARAMS}; 3use rusqlite::{Connection, OpenFlags, NO_PARAMS};
3 4
5use std::fmt;
4use std::path::Path; 6use std::path::Path;
5 7
6pub fn init_db<P: AsRef<Path>>(p: P) -> Result<Connection> { 8pub fn init_db<P: AsRef<Path> + fmt::Display>(p: P) -> Result<Connection> {
9 debug!("Looking for database at `{}`", p);
7 let conn = Connection::open_with_flags( 10 let conn = Connection::open_with_flags(
8 p, 11 &p,
9 OpenFlags::SQLITE_OPEN_CREATE | OpenFlags::SQLITE_OPEN_READ_WRITE, 12 OpenFlags::SQLITE_OPEN_CREATE | OpenFlags::SQLITE_OPEN_READ_WRITE,
10 )?; 13 )?;
11 conn.execute( 14 conn.execute(
@@ -15,5 +18,6 @@ pub fn init_db<P: AsRef<Path>>(p: P) -> Result<Connection> {
15 )", 18 )",
16 NO_PARAMS, 19 NO_PARAMS,
17 )?; 20 )?;
21 info!("SQLite3 database `{}` initialized", &p);
18 return Ok(conn); 22 return Ok(conn);
19} 23}