Percentage of LIKE for pymysql

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

Percentage of LIKE for pymysql
Overview of Docker (for beginners)
Implementation of Scale-space for SIFT
Rewrite piecewise of NumPy for CuPy
[Must-see for beginners] Basics of Linux
Survey for practical use of BlockChain
An implementation of ArcFace for TensorFlow
4th night of loop with for
Introductory table of contents for python3
Record of Python introduction for newcomers
[For competition professionals] Summary of doubling