moviequotebot-api/src/lib.rs
Louis Vallat a5649447ff Initial commit
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2021-06-09 11:53:04 +02:00

8 lines
308 B
Rust

use diesel::pg::PgConnection;
use std::env;
use diesel::Connection;
pub async fn establish_connection() -> PgConnection {
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
PgConnection::establish(&database_url).expect(&format!("Error connecting to {}", database_url))
}