diff --git a/oneshot.js b/oneshot.js new file mode 100644 index 0000000..31bfc09 --- /dev/null +++ b/oneshot.js @@ -0,0 +1,60 @@ +import sqlite3 from "sqlite3"; + +// Öffne die Datenbank +const db = new sqlite3.Database("imposter.db"); + +// Erstelle die Tabelle, falls sie nicht existiert +db.run(`CREATE TABLE IF NOT EXISTS words ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + word TEXT NOT NULL, + imposterWord TEXT NOT NULL, + inUse BOOL +)`); + +// Array mit sinnvollen Wortpaaren für das Imposter-Spiel +const wordPairs = [ + { word: "Hund", imposterWord: "Tier" }, + { word: "Auto", imposterWord: "Fahrzeug" }, + { word: "Haus", imposterWord: "Gebäude" }, + { word: "Apfel", imposterWord: "Obst" }, + { word: "Buch", imposterWord: "Lesen" }, + { word: "Computer", imposterWord: "Technik" }, + { word: "Meer", imposterWord: "Wasser" }, + { word: "Berg", imposterWord: "Natur" }, + { word: "Schule", imposterWord: "Lernen" }, + { word: "Musik", imposterWord: "Klang" }, + { word: "Sonne", imposterWord: "Licht" }, + { word: "Mond", imposterWord: "Nacht" }, + { word: "Baum", imposterWord: "Pflanze" }, + { word: "Flugzeug", imposterWord: "Fliegen" }, + { word: "Zug", imposterWord: "Reisen" }, + { word: "Pizza", imposterWord: "Essen" }, + { word: "Fußball", imposterWord: "Sport" }, + { word: "Kino", imposterWord: "Film" }, + { word: "Telefon", imposterWord: "Kommunikation" }, + { word: "Uhr", imposterWord: "Zeit" } +]; + +// Füge jedes Wortpaar in die Datenbank ein +wordPairs.forEach(pair => { + db.run( + `INSERT INTO words (word, imposterWord, inUse) VALUES (?, ?, ?)`, + [pair.word, pair.imposterWord, 0], + function(err) { + if (err) { + console.error("Fehler beim Einfügen:", err); + } else { + console.log(`Eingefügt: ${pair.word} - ${pair.imposterWord}`); + } + } + ); +}); + +// Schließe die Datenbank nach allen Operationen +db.close((err) => { + if (err) { + console.error("Fehler beim Schließen der DB:", err); + } else { + console.log("Datenbank erfolgreich gefüllt und geschlossen."); + } +});