Compare commits
2 Commits
0864dae481
...
ac9c9a4446
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac9c9a4446 | ||
|
|
8ed28160c2 |
|
|
@ -10,7 +10,6 @@ def add_data_to_einsaetze(name, location, date, time, etype, device):
|
|||
data = (name, location, date, time, etype, device)
|
||||
|
||||
cursor.execute(sql_query, data)
|
||||
print("DB geschrieben")
|
||||
|
||||
connection.commit()
|
||||
connection.close()
|
||||
|
|
@ -39,7 +38,9 @@ def get_entrys():
|
|||
''')
|
||||
data = cursor.fetchall()
|
||||
connection.close()
|
||||
return [dict(row) for row in data]
|
||||
d = [dict(row) for row in data]
|
||||
print (d)
|
||||
return d
|
||||
|
||||
|
||||
# ATS Träger aus DB Löschen ODER einfügen.abs
|
||||
|
|
@ -61,3 +62,8 @@ def get_ats_with_id():
|
|||
|
||||
|
||||
def delete_entry(entry_id):
|
||||
connection = sqlite3.connect(DB_NAME)
|
||||
cursor = connection.cursor()
|
||||
|
||||
cursor.execute("DELETE FROM entrys WHERE id = ?", (entry_id,))
|
||||
connection.commit()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ def initialize_db():
|
|||
connection = sqlite3.connect(DB_NAME)
|
||||
cursor = connection.cursor()
|
||||
|
||||
# --- Tabelle 1: Die Liste für dein Dropdown ---
|
||||
cursor.execute("PRAGMA foreign_keys = ON")
|
||||
|
||||
# --- Tabelle 1: BA Träger ---
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS ba_wearer (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
|
@ -15,7 +17,16 @@ def initialize_db():
|
|||
)
|
||||
''')
|
||||
|
||||
# --- Tabelle 2: Das Logbuch (jetzt mit Ort) ---
|
||||
# --- Tabelle 2: BA Geräte (muss VOR entrys erstellt werden!) ---
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS ba_devices (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT UNIQUE,
|
||||
code TEXT UNIQUE
|
||||
)
|
||||
''')
|
||||
|
||||
# --- Tabelle 3: Das Logbuch ---
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS entrys (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
|
|
@ -24,21 +35,13 @@ def initialize_db():
|
|||
date TEXT,
|
||||
time INTEGER,
|
||||
etype TEXT,
|
||||
device TEXT,
|
||||
device_id INTEGER,
|
||||
wearer_id INTEGER,
|
||||
FOREIGN KEY (wearer_id) REFERENCES ba_wearer(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (device_id) REFERENCES ba_devices(id) ON DELETE SET NULL
|
||||
)
|
||||
''')
|
||||
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS ba_devices (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT UNIQUE,
|
||||
code TEXT UNIQUE
|
||||
|
||||
)
|
||||
''')
|
||||
|
||||
# Optional: Ein paar Test-ats anlegen, falls die Tabelle leer ist
|
||||
cursor.execute("SELECT count(*) FROM ats")
|
||||
if cursor.fetchone()[0] == 0:
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -26,9 +26,7 @@ def setup_route():
|
|||
rows = data_api.get_entrys()
|
||||
|
||||
def delete_entry(entry_id: int):
|
||||
"""Hier deinen SQL DELETE Aufruf einfügen."""
|
||||
data_api.delete_entry(entry_id)
|
||||
print(f"Lösche Eintrag mit ID: {entry_id}")
|
||||
table.update()
|
||||
|
||||
table = ui.table(columns=columns, rows= rows, row_key='id').classes('w-full')
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ def setup_route():
|
|||
time = input_time.value
|
||||
etype = input_type.value
|
||||
device = input_device.value
|
||||
|
||||
# Hinweis: database Aufruf ist hier korrekt, sofern importiert
|
||||
data_api.add_data_to_einsaetze(name, location, date, time, etype, device)
|
||||
einsaetze_table.rows = data_api.get_entrys()
|
||||
einsaetze_table.update()
|
||||
ui.notify("Eintrag in Datenbank erstellt.")
|
||||
ClearForm()
|
||||
|
||||
|
||||
|
||||
|
|
@ -96,7 +96,6 @@ def setup_route():
|
|||
{'name': 'etype', 'label': 'Art', 'field': 'etype', "sortable": True},
|
||||
{'name': 'device', 'label': 'Gerät', 'field': 'device', "sortable": True},
|
||||
]
|
||||
# Die Tabelle selbst bekommt auch h-full, damit sie die Karte ausfüllt
|
||||
einsaetze_table = ui.table(
|
||||
columns = collums,
|
||||
rows = data_api.get_entrys(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user