From 6b3a68235a1115fb3947d6b796e07c64b82234d9 Mon Sep 17 00:00:00 2001 From: six <51x@keemail.me> Date: Mon, 10 Jan 2022 13:01:11 +0100 Subject: [PATCH] SQLite --- code/src/main.rs | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/code/src/main.rs b/code/src/main.rs index 938a2b2..6d3c1a9 100644 --- a/code/src/main.rs +++ b/code/src/main.rs @@ -1,16 +1,35 @@ use std::io::stdin; use std::fs; +use rusqlite::{Connection, Result}; +use rusqlite::NO_PARAMS; fn main() { - // Input to skills + // Input from cli let mut input_string = String::new(); stdin().read_line(&mut input_string).ok().expect("Error while reading input."); println!("{:?}", input_string); - // Read Skills - format? - let content = fs::read_to_string("../../skills.txt").expect("Error while reading file."); - println!("All skills:\n{}", content) + // Read Skills files -> sqlite? + //let content = fs::read_to_string("../../skills.txt").expect("Error while reading file."); + //println!("All skills:\n{}", content) - // List skill levels - // ... + let conn = Connection::open("irlpg.db")?; + + conn.execute( + "create table if not exists skill_levels ( + id integer primary key, + name text not null unique + )", + NO_PARAMS, + )?; + conn.execute( + "create table if not exists skills ( + id integer primary key, + name text not null, + color_id integer not null references skill_levels(id) + )", + NO_PARAMS, + )?; + + Ok(()) }