diff --git a/__pycache__/database.cpython-312.pyc b/__pycache__/database.cpython-312.pyc index e2da906..df6949c 100644 Binary files a/__pycache__/database.cpython-312.pyc and b/__pycache__/database.cpython-312.pyc differ diff --git a/ats_doku.db b/ats_doku.db index 5c57ad8..9438ee0 100644 Binary files a/ats_doku.db and b/ats_doku.db differ diff --git a/database.py b/database.py index 81b75c8..c6a314f 100644 --- a/database.py +++ b/database.py @@ -40,7 +40,7 @@ def add_data_to_einsaetze(name, location, date, time): connection = sqlite3.connect(DB_NAME) cursor = connection.cursor() - sql_query = "INSERT INTO einsaetze (name, ort, datum, zeit) VALUES (?, ?, ?, ?)" + sql_query = "INSERT INTO einsaetze (name, location, date, time) VALUES (?, ?, ?, ?)" data = (name, location, date, time) cursor.execute(sql_query, data) @@ -62,14 +62,13 @@ def get_ats_names(): def get_einsaetze(): connection = sqlite3.connect(DB_NAME) - cursor = connection.cursor() - + #Get Data an Row Names connection.row_factory = sqlite3.Row + cursor = connection.cursor() cursor.execute("SELECT * FROM einsaetze ORDER BY id DESC") data = cursor.fetchall() - connection.commit() connection.close() return [dict(row) for row in data] diff --git a/gui/__pycache__/main_gui.cpython-312.pyc b/gui/__pycache__/main_gui.cpython-312.pyc index 454b7bd..4f7ed63 100644 Binary files a/gui/__pycache__/main_gui.cpython-312.pyc and b/gui/__pycache__/main_gui.cpython-312.pyc differ diff --git a/gui/main_gui.py b/gui/main_gui.py index 5fc0769..2213070 100644 --- a/gui/main_gui.py +++ b/gui/main_gui.py @@ -42,6 +42,10 @@ def build_ui(): time = input_time.value database.add_data_to_einsaetze(name, location, date, time) print (name, location, date, time) + + einsaetze_table.rows = database.get_einsaetze() + einsaetze_table.update() + ui.notify("Eintrag in Datenbank erstellt.") def ClearForm(): @@ -59,7 +63,17 @@ def build_ui(): with ui.card().classes('flex-1 h-[85vh] p-0'): - ui.label("PLACEHOLDER ##### Datenbankeinträge aus Alten Einsätzen.") + collums = [ + {'name': 'date', 'label': 'Datum', 'field': 'date', 'sortable': True, 'align': 'left'}, + {'name': 'name', 'label': 'Name', 'field': 'name', 'sortable': True, 'align': 'left'}, + {'name': 'location', 'label': 'Ort', 'field': 'location', 'align': 'left'}, + {'name': 'time', 'label': 'Dauer', 'field': 'time'}, + ] + einsaetze_table = ui.table( + columns = collums, + rows = database.get_einsaetze(), + row_key = "id" + ).classes("w-full h-full")