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

use sqlx::{sqlite::SqlitePoolOptions, 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)
}