I am making a program where you can search if something is in an sqlite3 database.
def search():
tk = Tk()
tk.geometry('500x500')
def create():
gette = entt.get()
conn = sqlite3.connect('friend.db')
with conn:
cursor = conn.cursor()
cursor.execute('SELECT * FROM Photos WHERE name1=?', gette)
conn.commit()
result = cursor.fetchall()
print(result)
The program only works when I search 1 letter things. When I try something else, it says that there is incorrect number of binding supplies. It also says that the current statement uses 1, while there is how many letters I gave supplied. If anyone knows how to fix this, that would be greatly appreciated.
The Cursor.execute() method expects a sequence as second parameter. You are supplying a string which happens to be 8 characters long.
Use the following form instead:
cursor.execute('SELECT * FROM Photos WHERE name1=?', [gette])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.