diff --git a/src/main.rs b/src/main.rs index 2e0f4cb..a6c33bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,13 @@ use std::{ error::Error, }; use serde::Deserialize; +use sqlx::{ + prelude::*, + sqlite::{ + SqliteConnection, + SqliteConnectOptions, + }, +}; const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite"; @@ -48,6 +55,15 @@ fn main() -> Result<(), Box> { Ok(()) } +/// Prepare sqlite database connection +#[cfg(feature = "sqlite")] +async fn connect_sqlite(path: &PathBuf) -> sqlx::Result { + let connect_options = SqliteConnectOptions::new() + .filename(&path) + .create_if_missing(true); + SqliteConnection::connect_with(&connect_options).await +} + /// fn get_config(options: &Options) -> std::io::Result { let mut config_file = File::open(&options.config)?;