How can I import data from a text file into a database without giving a primary key in the text file?
So I have a table where I have 3 columns: ID, firstName, lastName.
ID is auto incremented. I would like to read in the names from the text file like that:
John, Smith; Michael, Jordan;
I don't want to use the primary key, as I don't know what will be the next primary key in the table, that should be done by auto increment.
If I use the text file like this, than I get the error message: Invalid column count...
The settings:
Columns separated with: ,
Columns enclosed with: "
Columns escaped with: \
Lines terminated with: ;
If I use the text file like this:
21, John, Smith; 22, Michael, Jordan;
The file can be imported (with the strange behavior that it tries to read the 3 empty line too, and sends an error, this one I don't understand either, but its a different topic)
This is the dump from the table:
CREATE TABLE IF NOT EXISTS `LoginData2` (
`FirstName` varchar(10) NOT NULL,
`LastName` varchar(10) NOT NULL,
`ID` int(4) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;