blob: 505a7889f1104c2f8443909391b5fd67c7775bc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  | 
use std::env;
use mysql;
use errors::*;
pub fn get_database_connection() -> Result<mysql::PooledConn> {
    let connection_url = env::var("DATABASE_URL")
        .chain_err(|| "DATABASE_URL environment variable not found")?;
    let pool = mysql::Pool::new_manual(10, 50, connection_url)?;
    let cx = pool.get_conn()?;
    Ok(cx)
}
  |