generated from t/malachite
Initial commit
This commit is contained in:
commit
f70b92c558
21 changed files with 6847 additions and 0 deletions
29
src/database/mod.rs
Normal file
29
src/database/mod.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
mod sql;
|
||||
|
||||
use crate::config::Config;
|
||||
use oiseau::{execute, postgres::DataManager as OiseauManager, postgres::Result as PgResult};
|
||||
use tetratto_core::model::{Error, Result};
|
||||
|
||||
pub const NAME_REGEX: &str = r"[^\w_\-\.,!]+";
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DataManager(pub OiseauManager<Config>);
|
||||
|
||||
impl DataManager {
|
||||
/// Create a new [`DataManager`].
|
||||
pub async fn new(config: Config) -> PgResult<Self> {
|
||||
Ok(Self(OiseauManager::new(config).await?))
|
||||
}
|
||||
|
||||
/// Initialize tables.
|
||||
pub async fn init(&self) -> Result<()> {
|
||||
let conn = match self.0.connect().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||
};
|
||||
|
||||
// execute!(&conn, sql::CREATE_TABLE_ENTRIES).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
1
src/database/sql/mod.rs
Normal file
1
src/database/sql/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
// pub const CREATE_TABLE_ENTRIES: &str = include_str!("./create_entries.sql");
|
Loading…
Add table
Add a link
Reference in a new issue