diff --git a/main.py b/main.py index b20a906..5dad282 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,30 @@ templates = Jinja2Templates(directory="templates") SSH_KEY = os.path.expanduser("~/.ssh/id_rsa") DB_PATH = "cluster.db" +# --- DATENBANK INITIALISIERUNG (WICHTIG!) --- +def init_db(): + conn = sqlite3.connect(DB_PATH) + # Wir stellen sicher, dass die Tabelle existiert + conn.execute(''' + CREATE TABLE IF NOT EXISTS nodes ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT, + ip TEXT UNIQUE, + user TEXT, + status TEXT + ) + ''') + conn.commit() + conn.close() + +# Diese Funktion wird JETZT beim Start aufgerufen +init_db() + +def get_db(): + conn = sqlite3.connect(DB_PATH) + conn.row_factory = sqlite3.Row + return conn + # --- WebSocket Manager --- class ConnectionManager: def __init__(self):