47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
import sys
|
|
import os
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from database.connection import get_db_connection
|
|
|
|
def check():
|
|
try:
|
|
with get_db_connection() as conn:
|
|
with conn.cursor(dictionary=True) as cursor:
|
|
# Check tables
|
|
cursor.execute("SHOW TABLES")
|
|
tables = cursor.fetchall()
|
|
print("Tables in database:", [list(t.values())[0] for t in tables])
|
|
|
|
# Check equipment table structure and data
|
|
cursor.execute("DESCRIBE equipment")
|
|
cols = cursor.fetchall()
|
|
print("\nEquipment columns:")
|
|
for c in cols:
|
|
print(f" {c['Field']}: {c['Type']}")
|
|
|
|
cursor.execute("SELECT * FROM equipment")
|
|
eqs = cursor.fetchall()
|
|
print(f"\nEquipment rows ({len(eqs)}):")
|
|
for eq in eqs:
|
|
print(" ", eq)
|
|
|
|
# Check machine_status table structure
|
|
cursor.execute("DESCRIBE machine_status")
|
|
cols = cursor.fetchall()
|
|
print("\nmachine_status columns:")
|
|
for c in cols:
|
|
print(f" {c['Field']}: {c['Type']}")
|
|
|
|
cursor.execute("SELECT * FROM machine_status")
|
|
statuses = cursor.fetchall()
|
|
print(f"\nmachine_status rows ({len(statuses)}):")
|
|
for s in statuses:
|
|
print(" ", s)
|
|
except Exception as e:
|
|
print("Error during check:", e)
|
|
|
|
if __name__ == "__main__":
|
|
check()
|