import MySQLdb
conn = MySQLdb.connect("127.0.0.1","root","123456","test",charset="utf8")
-sharp
sql = "insert into userinfo(usernamne,pwd) values(%s,%s)"
li = [("name1","338"),("name2","313")]
cur = conn.cursor()
try:
reCount = cur.executemany(sql,li)
conn.commit()
print(reCount)
except:
conn.rollback()
print("DB")
cur.close()
conn.close()
Database link is normal, because inserting a single statement is good, but when using cur.executemany to insert multiple pieces of data, it cannot be executed normally. The syntax has been checked many times to make sure there is no problem, and is there any useful tool for python debugging mysql? You can"t afford to get hurt with the naked eye.
the question is null and void. I wrote col username.