conn = MySQLdb.connect(hostip, username, password, dbname)
cur = conn.cursor()
tablename = raw_input("Choose your table name: ")
if tablename:
cur.execute("SELECT * FROM %s" % tablename)
rows = cur.fetchall()
desc = cur.description
fields = [j[0] for j in desc]
for row in rows:
for kword in dust:
for fs in fields:
cur.execute("SELECT * FROM %s WHERE %s LIKE '%%s%'" % (tablename, fs, kword))
conn.close()
#
Like the simple code, i want to pass the params use %% PlaceHolder in mysqldb, but it doesn’t worked, can somehelp me with that sentence? ‘%%s%’ , first and last ‘%’ is sql syntax that use ‘like’
THANKS VERY MUCH !
There are two ways of format string using %s and {} show example as below:
To solve your problem: