How to escape % in a query using python's sqlalchemy's execute() and pymysql?
Since this is a literal string, you're better off using a bound parameter here (illustrated using text()
):
from sqlalchemy import text
connection.execute(
text("select * from table where "
"string like :string limit 1"),
string="_stringStart%")