import MySQL. Connector db2 = mysql.connector.connect(host="localhost", port="3306", user="root", database="DB9db"); db2cursor=db2.cursor() #sql="INSERT INTO novatable3 (Nid,Namee,Gender,Age,Qualification,DoB) values (%s, %s, %s, %s, %s, %s)" #var=("33","summeya","F","17","bsc","2005") sql="INSERT INTO chktbl (name, salary) values (%s, %s)" var=[("summeya",33),("summeya",33),("summeya",33),("summeya",33),("summeya",33),("summeya",33),("summeya",33),("summeya",33)] db2cursor.executemany(sql, var) # print(db2cursor.rowcount,"records insertd") db2cursor.commit()
commit()
不會將任何資料儲存到我的 apache MySQL 資料庫。在Python程式碼中MySQL-connecter
在程式碼中,您已在遊標物件上呼叫了
commit()
方法,但您應該在資料庫連接物件上呼叫它。