From 5772c265377bb64468a214c738e7d92845ccd0c4 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 10 Feb 2024 13:35:39 +0000 Subject: [PATCH] database: accept connection string as argument --- src/db.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/db.rs b/src/db.rs index dd7d1b5..f0b36bd 100644 --- a/src/db.rs +++ b/src/db.rs @@ -6,9 +6,6 @@ use tracing::instrument; use crate::secrets::UserToken; -// TODO: allow configuring this via envar -const DB_URI_DEFAULT: &str = "sqlite://sqlite.db"; - // TODO: check again if it's possible to pass this as a parameter to query! // const TABLE_USER_TOKENS: &str = "user_tokens"; @@ -38,8 +35,8 @@ pub struct SqliteDatabase { impl SqliteDatabase { #[instrument] - pub async fn open() -> Self { - let options = SqliteConnectOptions::from_str(DB_URI_DEFAULT) + pub async fn open(connection_string: &str) -> Self { + let options = SqliteConnectOptions::from_str(connection_string) .expect("Invalid database URI") .create_if_missing(true);