/
main.rs
50 lines (40 loc) · 1.07 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use hesoyam::client::{ClickhouseConfig, ClientManager, PostgresConfig};
use hesoyam::error::*;
use crate::model::Entity;
mod example_model_impl;
mod example_model;
mod example_raw_query;
mod model;
fn run() -> Result<()> {
let pg_conf = PostgresConfig::new().
host("").
user("").
password("").
port(5432).
database("");
let ch_conf = ClickhouseConfig::new().
schema("http").
hostname("").
username("").
password("").
port(8123);
let mut cm = ClientManager::new().
add_client(&pg_conf)?.
add_client(&ch_conf)?;
// example_raw_query::execute(&mut cm)?;
// example_model::execute(&mut cm)?;
// example_model_impl::execute()?;
let client = cm.get_client("postgres")?;
let res = client.query("select * from entity")?;
for r in res {
let e: Entity = r.into();
println!("{:#?}", e);
}
Ok(())
}
fn main() {
match run() {
Ok(_) => println!("It seems all is OK :)"),
Err(e) => println!("Got an error: {}", e),
};
}