-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move sqlite connection function to database.rs
- Loading branch information
1 parent
f23a2d1
commit 2d4532a
Showing
4 changed files
with
27 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::env; | ||
|
||
use sqlite::Connection; | ||
use tracing::error; | ||
|
||
pub fn initialise_sqlite_connection() -> Connection { | ||
let path = match env::var("DBPATH") { | ||
Ok(env) => env, | ||
Err(_) => "sqlite.db".to_owned(), | ||
}; | ||
let conn = match sqlite::open(path) { | ||
Ok(conn) => conn, | ||
Err(e) => { | ||
error!("error establishing sqlite db connection: {e}"); | ||
panic!(); | ||
} | ||
}; | ||
return conn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod database; | ||
mod routes; | ||
mod setup; | ||
use axum::Router; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters