wip
This commit is contained in:
parent
66b3a99814
commit
98be8dd574
13 changed files with 329 additions and 46 deletions
19
src/database.rs
Normal file
19
src/database.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use anyhow::{anyhow, Context, Result};
|
||||
use sqlx::{sqlite::{SqliteConnectOptions, SqlitePoolOptions}, Pool, Sqlite, ConnectOptions};
|
||||
use std::str::FromStr;
|
||||
|
||||
pub async fn prepare_database(sqlite_db_path: &str) -> Result<Pool<Sqlite>> {
|
||||
let conn_str = format!("sqlite:{}", sqlite_db_path);
|
||||
|
||||
let pool = SqlitePoolOptions::new()
|
||||
.max_connections(50)
|
||||
.connect_with(
|
||||
SqliteConnectOptions::from_str(&conn_str)?
|
||||
.log_statements(log::LevelFilter::Trace)
|
||||
)
|
||||
.await
|
||||
.context("could not connect to database_url")?;
|
||||
|
||||
Ok(pool)
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue