summaryrefslogtreecommitdiffstats
path: root/src/remote/database.rs
blob: 4f386defa26236e724830d546681b878f6b0ecab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use diesel::pg::PgConnection;
use diesel::prelude::*;

use crate::settings::Settings;

#[database("atuin")]
pub struct AtuinDbConn(diesel::PgConnection);

// TODO: connection pooling
pub fn establish_connection(settings: &Settings) -> PgConnection {
    let database_url = &settings.remote.db.url;
    PgConnection::establish(database_url)
        .unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
}