prev work

This commit is contained in:
2025-12-25 22:29:59 +01:00
parent bced226cbd
commit d09a875488
6 changed files with 69 additions and 2 deletions

View File

@@ -91,11 +91,19 @@ class DatabaseConnect:
return False
else:
return res[0] == 1
def get_all_perms(self) -> list[tuple[str, str, bool, bool, bool]]:
self.cursor.execute("SELECT users.`username`, rooms.`shortname`, permissions.`view`, permissions.`control`, permissions.`administer` FROM permissions LEFT JOIN users ON permissions.`userID` = users.`ID` LEFT JOIN rooms ON permissions.`roomID` = rooms.`ID`;")
return [x for x in self.cursor.fetchall()]
# def roomID_from_shortname(self, shortname):
# self.cursor.execute("SELECT rooms.`ID` from rooms WHERE rooms.shortname = ?;",(shortname,))
# return self.cursor.fetchone()
def get_devices_in_room_shortname(self, shortname) -> list[tuple[int, str]]:
self.cursor.execute("Select devices.`ID`, devices.`name` FROM devices LEFT JOIN rooms ON devices.`roomID` = rooms.`ID` WHERE rooms.shortname = ?;",(shortname,))
return [x for x in self.cursor.fetchall()]
def get_sensors_in_room_shortname(self, shortname) -> list[tuple[int, int]]:
self.cursor.execute("Select sensors.`ID`, sensors.`Type` FROM sensors LEFT JOIN devices ON devices.`ID` = sensors.`deviceID` LEFT JOIN rooms ON devices.`roomID` = rooms.`ID` WHERE rooms.shortname = ?;",(shortname,))
return [x for x in self.cursor.fetchall()]