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

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

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

	Ok(pool)
}