Archived
1
0
Fork 0
This repository has been archived on 2024-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
enve/examples/diesel/src/db.rs

10 lines
289 B
Rust
Raw Normal View History

2020-03-12 23:20:34 +03:00
use super::config;
2019-12-29 01:11:34 +03:00
use diesel::pg::PgConnection;
2020-07-02 23:24:17 +05:30
use diesel::prelude::*;
2019-12-29 01:11:34 +03:00
pub fn establish_connection() -> PgConnection {
2020-03-12 23:20:34 +03:00
let database_url = config::DATABASE_URL();
PgConnection::establish(database_url)
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
2019-12-29 01:11:34 +03:00
}