moviequotebot-api/src/lib.rs

8 lines
308 B
Rust
Raw Normal View History

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))
}