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()
#
像简单的代码一样,我想在 mysqldb 中传递参数 use %% PlaceHolder ,但它不起作用,有人能帮我解决这句话吗?'%%s%' ,第一个和最后一个 '%' 是使用 'like' 的 sql 语法 非常感谢!