blob: 3c885897056400a2b1e0e488a36ba35ea8392874 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
use anyhow::{Context, Result};
use diesel::{Connection, SqliteConnection};
use crate::{actualbudget_state::read_actualbudget_state, schist_state::export_schist_state, transform_state::transform_state};
pub fn run(in_db_url: &str, out_db_url: &str) -> Result<()> {
let actualbudget_connection = &mut SqliteConnection::establish(in_db_url)
.with_context(|| format!(
"failed to establish connection to input database at {}",
in_db_url,
))?;
let schist_connection = &mut SqliteConnection::establish(out_db_url)
.with_context(|| format!(
"failed to establish connection to output database at {}",
out_db_url,
))?;
let actualbudget_state = read_actualbudget_state(actualbudget_connection)?;
let schist_state = transform_state(actualbudget_state)?;
export_schist_state(&schist_state, schist_connection)?;
Ok(())
}
|