database: accept connection string as argument
This commit is contained in:
parent
dfa8cada5b
commit
5772c26537
1 changed files with 2 additions and 5 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue