import pymysql
mysql_conn = pymysql.connect(host='127.0.0.1', user='root', password='mysql', db='test')
mysql_conn.autocommit(False)
cur1 = mysql_conn.cursor()
his_list = ["a","b","c","d","e","f","g","h"]
args = ','.join(['%s']*len(his_list))
sql = """DELETE FROM test WHERE test_i IN (%s) """ % (args)
print(sql)
cur1.execute(sql, his_list)
网友评论