Files
wecom_it_smart_desk/backend/check_all_tables.py

30 lines
1000 B
Python

import sqlite3
conn = sqlite3.connect('it_smart_desk.db')
cursor = conn.cursor()
# Check employee table
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='employees'")
if cursor.fetchone():
cursor.execute('PRAGMA table_info(employees)')
cols = [row[1] for row in cursor.fetchall()]
print('Employee columns:')
for c in cols:
print(f' {c}')
missing = ['it_level', 'it_level_source', 'notes']
for m in missing:
status = "EXISTS" if m in cols else "MISSING!"
print(f'{m}: {status}')
else:
print("No employees table found")
# Check todo_items and troubleshooting_templates tables
for table in ['todo_items', 'troubleshooting_templates']:
cursor.execute(f"SELECT name FROM sqlite_master WHERE type='table' AND name='{table}'")
if cursor.fetchone():
print(f"\n{table} table: EXISTS")
else:
print(f"\n{table} table: NOT FOUND (will be auto-created by SQLAlchemy on first access)")
conn.close()