14 lines
377 B
Rust
14 lines
377 B
Rust
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")
|
|
}
|