I am trying to insert some data into a MySQL table using python. From my understanding, when you insert data into a table that has a column that auto increments, you don't need to give the values of said column. However, I am running into an issue where I do have enough values required to insert data. What am I doing wrong? I've looked on this site, w3schools, the MySQL docs, and it looks like I'm doing everything right. I am getting error: mysql.connector.errors.DataError: 1136 (21S01): Column count doesn't match value count at row 1
... HAND_HISTORY_DB_TABLES['Hands'] = ( "CREATE TABLE `Hands` (" " `HandID` int NOT NULL AUTO_INCREMENT PRIMARY KEY," " `HandNumber` int UNIQUE," " `HandDate` date NOT NULL," " `HandResults` float" ") ENGINE=InnoDB") ... hand_insert = "INSERT INTO Hands " \ "SELECT %s, %s, %s " \ "WHERE NOT EXISTS " \ "(SELECT HandNumber, HandDate, HandResults " \ "FROM Hands " \ "WHERE HandNumber = %s AND HandDate = %s AND HandResults = %s)" cursor.execute(hand_insert, (self.hand_number, self.date, self.result, self.hand_number, self.date, self.result)) ... https://stackoverflow.com/questions/66072601/auto-increment-value-required-but-why February 06, 2021 at 09:07AM
没有评论:
发表评论