python3.x
Using the library pymysql connection = pymysql.connect (...) I wanted to move the partial match LIKE statement
with connection.cursor() as cursor:
cursor.execute("SELECT c1 FROM ttt WHERE c2 LIKE 'abc%'", ())
ary = cursor.fetchall()
If you write
TypeError: not enough arguments for format string
Will be. To have pymysql ignore% It seems that you have to escape% with%.
with connection.cursor() as cursor:
cursor.execute("SELECT c1 FROM ttt WHERE c2 LIKE 'abc%%'", ())
ary = cursor.fetchall()
It worked with.
Recommended Posts