18 lines
387 B
Rust
18 lines
387 B
Rust
use sqlx::{PgPool};
|
|
use anyhow::*;
|
|
use sqlx::postgres::PgPoolOptions;
|
|
|
|
#[derive(Clone)]
|
|
pub struct DBApplication {
|
|
pool: PgPool
|
|
}
|
|
|
|
impl DBApplication {
|
|
pub async fn new(config: String) -> Result<DBApplication> {
|
|
let pool = PgPoolOptions::new()
|
|
.max_connections(5)
|
|
.connect(&config)
|
|
.await?;
|
|
Ok(DBApplication { pool })
|
|
}
|
|
} |