37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import sqlite3
|
|
|
|
conn = sqlite3.connect("icu_local.db")
|
|
c = conn.cursor()
|
|
|
|
# Check rooms
|
|
c.execute("SELECT * FROM icu_rooms")
|
|
rooms = c.fetchall()
|
|
c.execute("PRAGMA table_info(icu_rooms)")
|
|
room_cols = [col[1] for col in c.fetchall()]
|
|
print("=== Rooms ===")
|
|
for r in rooms:
|
|
print(dict(zip(room_cols, r)))
|
|
|
|
# Check displays
|
|
c.execute("SELECT * FROM display_devices")
|
|
devices = c.fetchall()
|
|
c.execute("PRAGMA table_info(display_devices)")
|
|
dev_cols = [col[1] for col in c.fetchall()]
|
|
print("\n=== Displays ===")
|
|
for d in devices:
|
|
print(dict(zip(dev_cols, d)))
|
|
|
|
# Assign room_id=1 to display id=1 if not already assigned
|
|
if rooms and devices:
|
|
room_id = rooms[0][0] # first room's id
|
|
device_id = devices[0][0] # first device's id
|
|
c.execute("UPDATE display_devices SET room_id = ? WHERE id = ?", (room_id, device_id))
|
|
conn.commit()
|
|
print(f"\nAssigned room id={room_id} to display id={device_id}")
|
|
|
|
# Verify
|
|
c.execute("SELECT id, device_id, room_id FROM display_devices WHERE id = ?", (device_id,))
|
|
print("Updated display:", c.fetchone())
|
|
|
|
conn.close()
|