aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: b770fa9375bf8029f0c766c03055067591a10271 (plain)
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
use clap::Parser;
use rusqlite;
use yaml_rust::yaml;


#[derive(clap::Parser, Debug)]
#[clap()]
struct Args {
    #[clap(subcommand)]
    command: Command,

    #[clap(long)]
    database: String,
}

#[derive(clap::Subcommand, Debug)]
enum Command {
    Insert,
    Select,
}


fn main() {
    println!("Hello, world!");

    let args = Args::parse();

    // Get column names from SQLite

    let mut dbconn = rusqlite::Connection::open("./test.db").unwrap();

    let text_data = std::fs::read_to_string("test2.yml").unwrap();

    let mut yaml_data = yaml::YamlLoader::load_from_str(&text_data).unwrap();

    yaqlite::insert(&mut dbconn, "people", &mut yaml_data).unwrap();

    dbg!(yaml_data);

    dbconn.close().unwrap();
}