'Tkinter SQlite - Search Function not working [duplicate]
Good evening,
This is a simple function reading the value of an entry widget and searching in the database for it. It won´t run. Could someone kindly point me to my rookie mistake?
This is the Function:
def find_search_term(self, search_term):
search_term = self.search_entry.get()
conn=sqlite3.connect("KTRmini.db")
c = conn.cursor()
c.execute("SELECT * FROM KTRmini_table WHERE discription LIKE "%search_term%",")
data=c.fetchone()[0]
print(discription)
conn.close()
This is the Error:
c.execute("SELECT * FROM KTRmini_table WHERE discription LIKE "%search_term%",") TypeError: not all arguments converted during string formatting
Solution 1:[1]
c.execute("SELECT * FROM KTRmini_table WHERE discription LIKE %?%", search_term)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user18190922 |
