Python MySQL speichert nicht in meiner Datenbanktabelle
P粉237647645
P粉237647645 2023-09-12 17:01:49
0
1
579

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() Speichert keine Daten in meiner Apache-MySQL-Datenbank. MySQL-Connecter

im Python-Code
P粉237647645
P粉237647645

Antworte allen(1)
P粉242741921

在代码中,您已在游标对象上调用了 commit() 方法,但您应该在数据库连接对象上调用它。

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage