'Not Working filter search using python and mysql
It is showing me no record after writing the 1. I have data on my database for 1. Can someone please help me to know where I am wrong here?
def searchDB():
try:
sqlCon = mysql.connect(host="localhost",user="root",password="*********",database="mydatabase")
cur =sqlCon.cursor ()
cur.execute ("select categoryname from category where "+ str(searchby.get())+ "Like '%" + str(search.get()) + "Like '%'")
result = cur.fetchall ()
if len(result) !=0:
self.category_records.delete(*self.category_records.get_children())
for row in result:
self.category_records.insert('',END,values =row)
sqlCon.commit()
sqlCon.close()
except:
tkinter.messagebox.showinfo("Data Search Form", "No such record Found")
Reset()
sqlCon.close()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
