Files
iDRAC_Info/update_db.py
2025-11-28 18:27:15 +09:00

28 lines
884 B
Python

import sqlite3
import os
db_path = r"D:\Code\iDRAC_Info\idrac_info\backend\instance\site.db"
if not os.path.exists(db_path):
print(f"Database not found at {db_path}")
else:
try:
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
# Check if column exists
cursor.execute("PRAGMA table_info(telegram_bots)")
columns = [info[1] for info in cursor.fetchall()]
if 'notification_types' not in columns:
print("Adding notification_types column...")
cursor.execute("ALTER TABLE telegram_bots ADD COLUMN notification_types VARCHAR(255) DEFAULT 'auth,activity,system'")
conn.commit()
print("Column added successfully.")
else:
print("Column already exists.")
conn.close()
except Exception as e:
print(f"Error: {e}")