diff options
Diffstat (limited to 'src/db.rs')
-rw-r--r-- | src/db.rs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ | |||
1 | use crate::Modloader; | ||
2 | |||
3 | pub fn insert_mod(id: String, name: String, current_version: String, old_versions: Vec<String>, mod_loader: Modloader, desired_mc_version: String) -> Result<(), sqlite::Error> { | ||
4 | |||
5 | let connection = sqlite::open("./data.db").unwrap(); | ||
6 | |||
7 | let loader = match mod_loader { | ||
8 | Modloader::Fabric => "fabric", | ||
9 | Modloader::Forge => "forge", | ||
10 | }; | ||
11 | |||
12 | let sql = format!("INSERT INTO mods VALUES ('{}', '{}', '{}', '{}', '{}', '{}')", id, name, current_version, old_versions.join("|"), loader, desired_mc_version); | ||
13 | |||
14 | dbg!(&sql); | ||
15 | |||
16 | connection.execute(sql) | ||
17 | |||
18 | } | ||