aboutsummaryrefslogtreecommitdiff
path: root/src/utils/db.rs
blob: e6e19462a5059da712206a2f261e5d31d738e198 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use sqlx::sqlite::SqlitePoolOptions;
use std::error::Error;
use sqlx::SqlitePool;

pub async fn get_pool() -> Result<SqlitePool, Box<dyn Error>> {
	let pool = SqlitePoolOptions::new()
		.max_connections(20)
		.connect(&std::env::var("DATABASE_URL")?)
		.await?;

	debug!(
		"connected to database at url '{}'",
		&std::env::var("DATABASE_URL")?
	);

	Ok(pool)
}