using python 3 trying to a mysql query in flask
SELECT title FROM Book WHERE title LIKE '%booktitlehere%';
From the input of my search form this is attempted flask implementation
search_string = search.data['search']
cur = mysql.connection.cursor()
likeString = "'%" + search_string + "%'"
cur.execute('''SELECT title FROM Book WHERE title LIKE %s;''',likeString)
Its not working tho getting this error when go to the page that holds this form
_mysql_exceptions.ProgrammingError: not all arguments converted during string formatting
I have tried adding the %% to escape the literal %
likeString = "'%%" + search_string + "%%'"
# print(like)
cur.execute("""SELECT title FROM Book WHERE title LIKE %s;""",likeString)
rv = cur.fetchall()
but still getting error
_mysql_exceptions.ProgrammingError: not all arguments converted during string formatting
also tried with double quotes around select
cur.execute("SELECT title FROM Book WHERE title LIKE %s;",likeString)