mirror of
https://github.com/PhoenixTwoFive/karaoqueue.git
synced 2025-05-19 19:11:49 +02:00
Properly pass user input to SQLite and fix searches with umlauts.
Resolves #3.
This commit is contained in:
parent
a8871c1106
commit
e9f43c0169
@ -89,15 +89,17 @@ def get_played_list():
|
|||||||
def get_song_list():
|
def get_song_list():
|
||||||
conn =open_db()
|
conn =open_db()
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute("SELECT Artist || \" - \" || Title AS Song, Id FROM songs")
|
cur.execute("SELECT Artist || \" - \" || Title AS Song, Id FROM songs;")
|
||||||
return cur.fetchall()
|
return cur.fetchall()
|
||||||
|
|
||||||
def get_song_completions(input_string):
|
def get_song_completions(input_string):
|
||||||
conn = open_db()
|
conn = open_db()
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
# Don't look, it burns...
|
# Don't look, it burns...
|
||||||
|
prepared_string = "%{0}%".format(input_string).upper() # "Test" -> "%TEST%"
|
||||||
|
print(prepared_string)
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"SELECT Title || \" - \" || Artist AS Song, Id FROM songs WHERE Song LIKE REPLACE(REPLACE(REPLACE(REPLACE(UPPER('%"+input_string+"%'),'ö','Ö'),'ü','Ü'),'ä','Ä'),'ß','ẞ') LIMIT 20")
|
"SELECT Title || \" - \" || Artist AS Song, Id FROM songs WHERE REPLACE(REPLACE(REPLACE(REPLACE(UPPER( SONG ),'ö','Ö'),'ü','Ü'),'ä','Ä'),'ß','ẞ') LIKE (?) LIMIT 20;", (prepared_string,))
|
||||||
return cur.fetchall()
|
return cur.fetchall()
|
||||||
|
|
||||||
def add_entry(name,song_id):
|
def add_entry(name,song_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user