You've already forked AstralRinth
forked from didirus/AstralRinth
Basic Database
This commit is contained in:
11
src/database/database.rs
Normal file
11
src/database/database.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use diesel::prelude::*;
|
||||
use diesel::pg::PgConnection;
|
||||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
|
||||
pub fn connect() -> PgConnection{
|
||||
dotenv.ok();
|
||||
|
||||
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set!");
|
||||
PgConnection::establish(&database_url).expect(&format!("Error connecting to {}", database_url))
|
||||
}
|
||||
Reference in New Issue
Block a user