brokkr-models Rust
Functions
brokkr-models::establish_connection
pub(crate)
#![allow(unused)]
fn main() {
fn establish_connection (database_url : String) -> PgConnection
}
Establishes a connection to the PostgreSQL database.
This function exists to manage migrations and perform basic testing in this crate without a specific Data Access Layer (DAL) in place.
Parameters:
| Name | Type | Description |
|---|---|---|
database_url | - | A string slice that holds the URL of the database to connect to. |
Returns:
PgConnection- A connection to the PostgreSQL database.
Raises:
| Exception | Description |
|---|---|
Panic | This function will panic if it fails to establish a connection to the database. |
Source
#![allow(unused)]
fn main() {
pub(crate) fn establish_connection(database_url: String) -> PgConnection {
PgConnection::establish(&database_url)
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
}
}