In my app I have a database of dinosaurs. The user types in the name of the dinosaur that they are looking for and it displays information about that particular dinosaur. The problem is that the user might not know the correct spelling of the name of the dinosaur that they are looking for and if the spelling of the name entered into the search box is not correct, it does not display anything. I wrote this same program in another language and used the 'LIKE' clause and if there was a typo, or the name was entered without capitalizing the first letter of the name, it still found the correct record and displayed it. I want to do the same using Python but I can't figure out how Python uses the LIKE clause. If anyone can give me an example I would greatly appreciate it.
Here is the code that I am using:
Here is the code that I am using:
def searchRec(recNo,e): dinoName=searchBox.get() conn=sqlite3.connect('dinobase.db') c=conn.cursor() c.execute('SELECT * FROM dino WHERE name LIKE :dinoName',{'dinoName': dinoName}) rows=c.fetchall() for row in rows: recNo = row[0] namebox.insert(0, row[1]) meaningbox.insert(0, row[2]) pronouncebox.insert(0, row[3]) periodbox.insert(0, row[4]) groupbox.insert(0, row[5]) sizebox.insert(0, row[6]) livedbox.insert(0, row[7]) dietbox.insert(0, row[8]) fossilsbox.insert(0, row[9]) factfilebox.insert(1.0, row[10]) c.close() conn.close()