I am making a program for a library using a database to store details about books, with tkinter as a gui. A feature of the program is where the user can enter the name of a book and it will search the database and return records with books containing that name. Here is the code I currently have for this feature:
def bookSearch(event):
top = Toplevel()
top.title("Book Search")
Label(top, text = "Enter the name of the book you are searching for: ").grid()
bookSearchEntry = Entry(top)
bookSearchEntry.grid(row = 0, column = 1)
def dbSearchForBooks(event):
getRecord = c.execute("Select * FROM bookList WHERE BookName = ?",(bookSearchEntry.get(),))
strGetRecord = str(getRecord)
t = Text(top, height = 100, width = 100) #creates a text widget where the records will be inserted into
t.grid(row = 1, column = 0, columnspan = 3) #packs the widget into the window
t.insert(END, strGetRecord + "\n") #inserts the records into the window
bookSearchButton = Button(top, text = "Search", command = dbSearchForBooks(event))
bookSearchButton.grid(row = 0, column = 2)
I am not getting any error messages with this code, however, it is just saying
<sqlite3.Cursor object at 0x0406B9E0>
in the text widget. It should be empty when the function is first run, then I enter the name of the book I am searching for e.g. "Harry Potter" and it should update the text widget with the row in the bookList table for the row where "Harry Potter" is the book name. The text widget does not update when I search, it is just constantly saying
<sqlite3.Cursor object at 0x0406B9E0>
I am stumped on how to fix this so any help is appreciated, thank you.
bookSearchButton=Button(..., command=dbSearchForBooks)