fix: sqlite ?mode=rwc, remove redundant libsqlite3-sys dep
This commit is contained in:
Generated
+1
@@ -941,6 +941,7 @@ dependencies = [
|
|||||||
"axum",
|
"axum",
|
||||||
"chrono",
|
"chrono",
|
||||||
"futures",
|
"futures",
|
||||||
|
"libsqlite3-sys",
|
||||||
"rumqttc",
|
"rumqttc",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
+12
-1
@@ -192,9 +192,20 @@ async fn main() {
|
|||||||
let db_path = std::env::var("NEWSBOARD_DB")
|
let db_path = std::env::var("NEWSBOARD_DB")
|
||||||
.unwrap_or_else(|_| "/var/lib/newsboard/news.db".into());
|
.unwrap_or_else(|_| "/var/lib/newsboard/news.db".into());
|
||||||
|
|
||||||
|
let db_path = std::env::var("NEWSBOARD_DB")
|
||||||
|
.unwrap_or_else(|_| "/var/lib/newsboard/news.db".into());
|
||||||
|
|
||||||
|
let url = if db_path == ":memory:" || db_path == "" {
|
||||||
|
"sqlite::memory:".to_string()
|
||||||
|
} else {
|
||||||
|
format!("sqlite:{}?mode=rwc", db_path)
|
||||||
|
};
|
||||||
|
|
||||||
|
tracing::info!(url = %url, "connecting to database");
|
||||||
|
|
||||||
let pool = SqlitePoolOptions::new()
|
let pool = SqlitePoolOptions::new()
|
||||||
.max_connections(5)
|
.max_connections(5)
|
||||||
.connect(&format!("sqlite:{db_path}"))
|
.connect(&url)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to connect to SQLite");
|
.expect("Failed to connect to SQLite");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user