Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tkinter SQlite – Search Function not working

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 :

c.execute("SELECT * FROM KTRmini_table WHERE discription LIKE %?%", search_term)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading