pre-metrics
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use sea_orm::{ConnectOptions, Database as SeaDatabase, DatabaseConnection, DbErr};
|
||||
use std::time::Duration;
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Database {
|
||||
pub connection: DatabaseConnection,
|
||||
@@ -9,7 +8,13 @@ pub struct Database {
|
||||
|
||||
impl Database {
|
||||
pub async fn init(dsn: &str) -> Result<Self, DbErr> {
|
||||
let mut opt = ConnectOptions::new(dsn);
|
||||
let mut final_dsn = dsn.to_string();
|
||||
if dsn.starts_with("sqlite:") && !dsn.contains('?') && dsn != "sqlite::memory:" {
|
||||
final_dsn = format!("{}?mode=rwc", dsn);
|
||||
}
|
||||
println!("{}", final_dsn);
|
||||
|
||||
let mut opt = ConnectOptions::new(final_dsn);
|
||||
opt.max_connections(100)
|
||||
.min_connections(5)
|
||||
.connect_timeout(Duration::from_secs(8))
|
||||
|
||||
Reference in New Issue
Block a user