chore: bootstrap housing research platform
This commit is contained in:
13
apps/api/src/db.rs
Normal file
13
apps/api/src/db.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use anyhow::{Context, Result};
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
use sqlx::PgPool;
|
||||
use std::time::Duration;
|
||||
|
||||
pub async fn create_pool(database_url: &str) -> Result<PgPool> {
|
||||
PgPoolOptions::new()
|
||||
.max_connections(8)
|
||||
.acquire_timeout(Duration::from_secs(5))
|
||||
.connect(database_url)
|
||||
.await
|
||||
.context("failed to connect to PostgreSQL")
|
||||
}
|
||||
Reference in New Issue
Block a user