diff --git a/src/database.rs b/src/database.rs index dead600..4df0cf2 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,5 +1,6 @@ use anyhow::Result; use sqlite::{ConnectionThreadSafe, Value}; +use std::time::Duration; #[derive(Debug)] pub struct Counter { @@ -16,8 +17,12 @@ pub struct Database { impl Database { pub fn new(name: &str) -> Result { + let mut connection = sqlite::Connection::open_thread_safe(name).expect("ORPS"); + connection.set_busy_timeout(5_000_000)?; + connection.execute("PRAGMA journal_mode = WAL;")?; let db = Database { - conn: sqlite::Connection::open_thread_safe(name)?, + conn: connection, + // conn: sqlite::Connection::open_thread_safe(name).expect("ORGIE"), }; db.init_database()?; db.get_default_counter()?;