Not sure how to get rid of type errors without jeopardizing functionality of LIKE operator - namely the % to indicate finding strings in the beginning, end, or throughout.
Trying to search for isbns of books that has the variable characters 380X.
Getting rid of % to fix type error returned an empty list.
isbn = request.form.get("search")
# Search the database for matching or part matching string, isbn, title, or author
book = db.execute("SELECT * FROM books WHERE isbn LIKE '%:isbn%'", {"isbn":str(isbn)}).fetchall()
expected: a list of books and their columns but i get this error:
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.SyntaxError) syntax error at or near "380" LINE 1: SELECT * FROM books WHERE isbn LIKE '%'380'%' ^
[SQL: SELECT * FROM books WHERE isbn LIKE '%%%(isbn)s%%']