fix: sqlite ?mode=rwc, remove redundant libsqlite3-sys dep
This commit is contained in:
Generated
+1
@@ -941,6 +941,7 @@ dependencies = [
|
||||
"axum",
|
||||
"chrono",
|
||||
"futures",
|
||||
"libsqlite3-sys",
|
||||
"rumqttc",
|
||||
"rust-embed",
|
||||
"serde",
|
||||
|
||||
+12
-1
@@ -192,9 +192,20 @@ async fn main() {
|
||||
let db_path = std::env::var("NEWSBOARD_DB")
|
||||
.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()
|
||||
.max_connections(5)
|
||||
.connect(&format!("sqlite:{db_path}"))
|
||||
.connect(&url)
|
||||
.await
|
||||
.expect("Failed to connect to SQLite");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user