I've been getting the error "mysql.connector.errors.DataError: 1136 (21S01): Column count doesn't match value count at row 1" after trying to enter the user details, but I don't see why:
def userEntry():
if myConnection:
cursor = myConnection.cursor()
createTable = """CREATE TABLE IF NOT EXISTS C_DETAILS(CID INT(11) AUTO_INCREMENT PRIMARY KEY, C_NAME VARCHAR(30),
C_ADDRESS VARCHAR(30), C_AGE INT(2),
C_COUNTRY VARCHAR(30), P_NO INT(10), C_EMAIL VARCHAR(30))"""
cursor.execute(createTable)
name = input("Enter Customer Name : ")
address = input("Enter Customer Address : ")
age = int(input("Enter Customer Age : "))
nationality = input("Enter Customer Country : ")
phoneno = int(input("Enter Customer Contact Number : "))
email = input("Enter Customer Email : ")
sql = "INSERT INTO C_Details VALUES(%s, %s, %s, %s, %s, %s)"
values = (name, address, age, nationality, phoneno, email)
cursor.execute(sql, values)
cursor.execute("COMMIT")
print("\nNew Customer Entered In The System Successfully!")
cursor.close()
else:
print("\nERROR ESTABLISHING MYSQL CONNECTION!")
I'm assuming that it's because of my AUTO_INCREMENT field, but I read that there's no need to add a parameter for that type of field.
Does anyone know what might be the issue?