Why didn't mysql insert multiple pieces of data successfully? There is no problem with the grammar check. I can't find the reason. Ask for help. Thank you.

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.

Mar.05,2021
Menu