I am doing project 1 and I have a problem. While doing the search page, I have show possible autocompleted texts to help the user with the search, but I don't know how to do that. I know it was shown somewhere in the lectures, but I haven't found it. Could someone give me some help? Thanks

1 Answer 1


You don't have to 'autocomplete' as per, you can execute a 'LIKE' query on the database with the input entered by the user, like the following:

book = ("%" + request.form.get("book") + "%").title()

results = db.execute("""SELECT * FROM books WHERE "ISBN" LIKE (:book) OR "Title" LIKE (:book) OR "Author" LIKE (:book)""", {"book" : book})

Here, the first statement ensures that the information you entered matches something in the database, case not mattering.(title() does that)
The second statement actually runs your query.

This answer's late, but hope it helps someone!!!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .