Answer the question
In order to leave comments, you need to log in
How to add variable to SQL query with "WHERE something LIKE" in Python?
Good day!
I wanted to quickly implement book search in Flask, but I can't add a variable to the expression:
@app.route("/book-<string:book>")
def book(book):
oneBook = db.execute("SELECT * FROM books WHERE title LIKE '%:book%' OR isbn LIKE '%:book%' OR author LIKE '%:book%'",
{"book": book}).fetchall()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question