The parameter placeholder cannot be inside a quoted string in the SQL expression. Otherwise there would be no way to use characters that look like a placeholder as a literal string in SQL.
So you must put the placeholder outside of a quoted string, and concatenate with the wildcards using the ||
string concatenation operator.
db.execute("""SELECT * FROM books
WHERE isbn LIKE '%'||:isbn||'%'
OR title LIKE '%'||:title||'%L'
OR author LIKE '%'||:author||'%'""",
{"isbn": isbn, "title": title, "author": author})
An alternative is to concatenate the value of the parameter with the %
SQL wildcard characters in Python, then pass the resulting string as the parameter. In this case, you can skip putting the wildcards in your query. Still don't put the parameter placeholder inside string quotes in the SQL expression.
db.execute("""SELECT * FROM books
WHERE isbn LIKE :isbn
OR title LIKE :title
OR author LIKE :author""",
{"isbn": "%"+isbn+"%", "title": "%"+title+"%L", "author": "%"+author+"%"})
P.S.: I edited your author =
to author LIKE
because you can't use wildcards with =
.
Also I think you have an extra L
after the title wildcard. But I don't know if this is intentional, so I left it in my example.