I am trying to run sql commands with python, but for some reason, its giving me error "Column count doesn't match value count at row 1". Tried everything but still didn't work. This is my code:-
import mysql.connector
mydb = mysql.connector.connect(host="localhost", user="root", passwd="###", database="student", auth_plugin="mysql_native_password")
cursor = mydb.cursor()
cursor.execute("insert into student(Rollno, Name, Class, marks) values(1,'carren','1B',100, 5,'john','2A',50)")
CodePudding user response:
Probably you need to separate the values:
cursor.execute("insert into student(Rollno, Name, Class, marks) values(1,'carren','1B',100), (5,'john','2A',50)")