File size: 379 Bytes
b7fdfb4
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use sqlx::PgPool;
use std::time::Duration;

pub async fn db() -> Result<PgPool, sqlx::Error> {
    let database_url = std::env::var("DATABASE_URL").expect("Database url not found!");
    let pool = sqlx::postgres::PgPoolOptions::new()
        .max_connections(15)
        .acquire_timeout(Duration::from_secs(10))
        .connect(&database_url)
        .await?;

    Ok(pool)
}