From fc1cb1acc0dce412e948475002666bcd1d4b0348 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 31 Oct 2022 22:41:18 +0100 Subject: add first impl --- src/db.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index e69de29..3d50b0f 100644 --- a/src/db.rs +++ b/src/db.rs @@ -0,0 +1,18 @@ +use crate::Modloader; + +pub fn insert_mod(id: String, name: String, current_version: String, old_versions: Vec, mod_loader: Modloader, desired_mc_version: String) -> Result<(), sqlite::Error> { + + let connection = sqlite::open("./data.db").unwrap(); + + let loader = match mod_loader { + Modloader::Fabric => "fabric", + Modloader::Forge => "forge", + }; + + let sql = format!("INSERT INTO mods VALUES ('{}', '{}', '{}', '{}', '{}', '{}')", id, name, current_version, old_versions.join("|"), loader, desired_mc_version); + + dbg!(&sql); + + connection.execute(sql) + +} -- cgit v1.2.3