Add method for preparing sqlite connection
This is not being used yet Co-authored-by: Erik Foris
This commit is contained in:
parent
e62f3ee2dc
commit
99918f1bb9
16
src/main.rs
16
src/main.rs
@ -7,6 +7,13 @@ use std::{
|
|||||||
error::Error,
|
error::Error,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use sqlx::{
|
||||||
|
prelude::*,
|
||||||
|
sqlite::{
|
||||||
|
SqliteConnection,
|
||||||
|
SqliteConnectOptions,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite";
|
const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite";
|
||||||
|
|
||||||
@ -48,6 +55,15 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Prepare sqlite database connection
|
||||||
|
#[cfg(feature = "sqlite")]
|
||||||
|
async fn connect_sqlite(path: &PathBuf) -> sqlx::Result<SqliteConnection> {
|
||||||
|
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<Config> {
|
fn get_config(options: &Options) -> std::io::Result<Config> {
|
||||||
let mut config_file = File::open(&options.config)?;
|
let mut config_file = File::open(&options.config)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user