Add search operators #10
@ -70,6 +70,17 @@ def search_by_pssh_or_kid(search_filter):
|
||||
try:
|
||||
with mysql.connector.connect(**get_db_config()) as conn:
|
||||
cursor = conn.cursor()
|
||||
if search_filter.lower().startswith("kid:"):
|
||||
value = search_filter[4:]
|
||||
|
||||
cursor.execute('SELECT PSSH, KID, `Key` FROM licenses WHERE KID = %s', (value,))
|
||||
results.update(cursor.fetchall())
|
||||
elif search_filter.lower().startswith("pssh:"):
|
||||
value = search_filter[5:]
|
||||
|
||||
cursor.execute('SELECT PSSH, KID, `Key` FROM licenses WHERE PSSH LIKE %s', (f"%{value}%",))
|
||||
results.update(cursor.fetchall())
|
||||
else:
|
||||
like_filter = f"%{search_filter}%"
|
||||
|
||||
cursor.execute('SELECT PSSH, KID, `Key` FROM licenses WHERE PSSH LIKE %s', (like_filter,))
|
||||
|
Loading…
x
Reference in New Issue
Block a user