idkthings_core 0.1.1

core stuff for idkthings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use log::info;
use sqlx::postgres::{PgPool, PgPoolOptions};
use std::env;

pub async fn create_db_client() -> PgPool {
    let connection_string = env::var("DB_CONNECTION_STRING").expect("DB_CONNECTION_STRING not set");

    info!("connecting to DB");
    let pool = PgPoolOptions::new()
        .max_connections(5)
        .connect(&connection_string)
        .await
        .expect("failed to connect to db");

    info!("DB connected");

    pool
}