Edited at

python sql文にパラメータを入れる方法

More than 1 year has passed since last update.

k="%パン%"

connector = MySQLdb.connect(host="*", port=*, db="*", user="*", passwd="*", charset="utf8")

cursor = connector.cursor()
sql1="SELECT * from * where word like %s"
cursor.execute(sql1, (k,))
cursor.close()
connector.close()