Die Abfrage scheint zu funktionieren, aber der "ausgewählte Eintrag" wird in eine Zeichenfolge aus Zahlen, die meine Abfrage durcheinander bringt. So erhalten Sie Eingabewert, um keine Zeichenfolgevariable für Mysql zu sein Abfrage = Tkinter
def find_roster(n=""):
global cursor
cursor.execute("""SELECT num, firstname, surname, assign FROM active WHERE num='%s'"""%(n))
rows = cursor.fetchall()
for results in rows:
rosterList.insert("end", results)
cursor.close()
print(n)
print(rows)
return rows
numLabel=Label(root, text="Employee #")
numLabel.grid(row=0,column=0)
findButt=Button(root, text="Find", width=12, command=find_roster)
findButt.grid(row=1, column=5)
num_input=StringVar()
num_input=Entry(root,textvariable=num_input)
num_input.grid(row=0,column=1)
-----
findButt=Button(root, text="Find", width=12, command=lambda: find_roster(num_input))
findButt.grid(row=1, column=5)
KONSOLE PRINT RESULT
.140526443864584
() #QUERY RESULT
BRAUCHT
WERDEN1-214
(1-214, JOE,HOEY,OFF) #QUERY RESULT
Verwendung Taste '{}' korrekt formatiert Code – furas
Bitte geben Sie [a Minimal, Complete, und prüfbare Beispiel] (https: // Stackoverflow .com/hilfe/mcve). – Nae