Version 1.2.6: Verbesserte Suchfunktion und Highlighting - app.py aktualisiert
This commit is contained in:
19
app.py
19
app.py
@@ -38,7 +38,7 @@ def init_db():
|
||||
conn = sqlite3.connect(DB_FILE)
|
||||
c = conn.cursor()
|
||||
|
||||
# Erstelle die Tabelle mit Indizes
|
||||
# Erstelle die Tabelle
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS customers (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -124,6 +124,19 @@ def import_csv():
|
||||
|
||||
def search_customers(search_params):
|
||||
"""Sucht nach Kunden basierend auf den Suchparametern."""
|
||||
# Prüfe, ob alle Suchfelder leer sind
|
||||
if not any([
|
||||
search_params.get('q'),
|
||||
search_params.get('name'),
|
||||
search_params.get('ort'),
|
||||
search_params.get('nummer'),
|
||||
search_params.get('plz'),
|
||||
search_params.get('telefon'),
|
||||
search_params.get('email'),
|
||||
search_params.get('fachrichtung')
|
||||
]):
|
||||
return []
|
||||
|
||||
conn = sqlite3.connect(DB_FILE)
|
||||
c = conn.cursor()
|
||||
|
||||
@@ -155,6 +168,10 @@ def search_customers(search_params):
|
||||
query += " AND plz LIKE ?"
|
||||
params.append(f"%{search_params['plz']}%")
|
||||
|
||||
if search_params.get('fachrichtung'):
|
||||
query += " AND fachrichtung LIKE ?"
|
||||
params.append(f"%{search_params['fachrichtung']}%")
|
||||
|
||||
# Führe die Abfrage aus
|
||||
c.execute(query, params)
|
||||
results = c.fetchall()
|
||||
|
Reference in New Issue
Block a user