55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
import sqlite3
|
|
from data.database import DB_NAME
|
|
|
|
|
|
def add_data_to_einsaetze(name, location, date, time, etype, device):
|
|
connection = sqlite3.connect(DB_NAME)
|
|
cursor = connection.cursor()
|
|
|
|
sql_query = "INSERT INTO einsaetze (name, location, date, time, etype, device) VALUES (?, ?, ?, ?, ?, ?)"
|
|
data = (name, location, date, time, etype, device)
|
|
|
|
cursor.execute(sql_query, data)
|
|
print("DB geschrieben")
|
|
|
|
connection.commit()
|
|
connection.close()
|
|
|
|
def get_ats_names():
|
|
connection = sqlite3.connect(DB_NAME)
|
|
cursor = connection.cursor()
|
|
|
|
# nur die Spalte 'name' aus der Tabelle 'ats'
|
|
cursor.execute("SELECT name FROM ats ORDER BY name ASC")
|
|
names = cursor.fetchall()
|
|
connection.close()
|
|
return [row[0] for row in names]
|
|
|
|
def get_einsaetze():
|
|
connection = sqlite3.connect(DB_NAME)
|
|
|
|
#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.close()
|
|
return [dict(row) for row in data]
|
|
|
|
|
|
# ATS Träger aus DB Löschen ODER einfügen.abs
|
|
def delete_ats_traeger(id):
|
|
connection = sqlite3.connect(DB_NAME)
|
|
|
|
cursor = connection.cursor()
|
|
|
|
def get_ats_with_id():
|
|
#Verbindung Aufbauen
|
|
connection = sqlite3.connect(DB_NAME)
|
|
connection.row_factory = sqlite3.Row
|
|
|
|
cursor = connection.cursor()
|
|
cursor.execute("SELECT id, name FROM ats ORDER BY name ASC")
|
|
|
|
data = cursor.fetchall()
|
|
return [dict(row) for row in data] |