1
逃逸MySQL的發言中,我將如何逃脫%,在以下幾點:麻煩蟒蛇
cursor.execute('''SELECT MIN(id) FROM title WHERE provider=%s
AND vendor_id LIKE "%s%"''', (provider, vendor_id_stem))
逃逸MySQL的發言中,我將如何逃脫%,在以下幾點:麻煩蟒蛇
cursor.execute('''SELECT MIN(id) FROM title WHERE provider=%s
AND vendor_id LIKE "%s%"''', (provider, vendor_id_stem))
cursor.execute("SELECT MIN(id) FROM title WHERE provider=%s"
"AND vendor_id LIKE '%s%%'", (provider, vendor_id_stem))
添加它作爲一個Python變量:
cursor.execute("SELECT MIN(id) FROM title WHERE provider=%s AND
vendor_id LIKE %s", (provider, vendor_id_stem + '%'))
你可以看一下這個版本的廣告問題:http://stackoverflow.com/questions/3037581/how-do-i-escape-from-python-mysql-query?rq=1 – kael 2013-05-10 22:45:39