this repo has no description
at main 520 B view raw
1//! create a connection pool and setup tables before making avaliable 2 3use crate::config; 4use sqlx::{Pool, Postgres, migrate, postgres::PgPool}; 5 6pub async fn conn() -> Pool<Postgres> { 7 let conn = match PgPool::connect(&config::DATABASE_URL).await { 8 Ok(val) => val, 9 Err(err) => { 10 panic!("Could not connect to the database. Got error {err}"); 11 } 12 }; 13 14 migrate!().run(&conn).await.unwrap_or_else(|err| { 15 panic!("Error running migrations: {}", err); 16 }); 17 18 conn 19}