Good day,
I'm working on a XAMPP database using Python and PyMysql. However, I'm having a problem with passing a %s string value when using CONCAT search.
import pymysql
connect_database = pymysql.connect(host='localhost', user="root", database='treeview_test')
cursor = connect_database.cursor()
search_input = str(input("Enter last name: "))
cursor.execute("SELECT * FROM `information` WHERE `last_name` LIKE CONCAT ('%', '%s', '%')" % (search_input))
data = cursor.fetchall()
print(data)
And this is the error:
cursor.execute("SELECT * FROM `information` WHERE `last_name` LIKE CONCAT ('%', '%s', '%')" % (search_input))
ValueError: unsupported format character ''' (0x27) at index 61
Please help, or maybe suggest other workaround on how to do this. I'm trying to create a search function that will search the last_name
column even if only part of the string is used as keyword.
Thanks in advance.