database: accept connection string as argument

This commit is contained in:
Xiretza 2024-02-10 13:35:39 +00:00
parent dfa8cada5b
commit 5772c26537

View file

@ -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);