python MySQL not saving to my database table
P粉237647645
P粉237647645 2023-09-12 17:01:49
0
1
574

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() does not save any data to my apache MySQL database. In Python code MySQL-connecter

P粉237647645
P粉237647645

reply all(1)
P粉242741921

In the code, you have called the commit() method on the cursor object, but you should call it on the database connection object.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template