diff options
author | Keuin <[email protected]> | 2024-02-29 00:41:45 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2024-02-29 00:50:10 +0800 |
commit | 399c35ad56526e406e33bfc6d7f5a861f3f9936f (patch) | |
tree | 7675857126625805f7320e60d8f74b0613f007c2 /src | |
parent | 1374f7151d7a5c0eaecb53eabbb048984eaa7a72 (diff) |
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 6bb7488..eb1bf74 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use futures_util::future::join_all; use futures_util::TryStreamExt; use serde_derive::{Deserialize, Serialize}; use sqlx::{Column, Row, SqlitePool}; +use sqlx::sqlite::SqliteConnectOptions; use sqlx::sqlite::SqlitePoolOptions; use tokio::task::JoinError; use tracing::{debug, info}; @@ -36,8 +37,11 @@ impl RelationReader { if cfg.fields.is_empty() { return Err(anyhow!("relation does not have any field")); } - // TODO make this configurable - match SqlitePoolOptions::new().max_connections(50).connect(&cfg.connect).await { + let opts = SqliteConnectOptions::new() + .filename(&cfg.connect).read_only(true) + .create_if_missing(false); + match SqlitePoolOptions::new() + .max_connections(50).connect_with(opts).await { Ok(p) => Ok(RelationReader { cfg: cfg.clone(), db: p, |