Import csv into sqlite with autoincrementing primary key Import csv into sqlite with autoincrementing primary key database database

Import csv into sqlite with autoincrementing primary key


An empty field in a CSV file is just an empty string, which is not valid for an INTEGER PRIMARY KEY column.

Import into a temporary table without that column, then copy the data over with:

INSERT INTO Allegiance(CharacterID, Title) SELECT * FROM TempTable;


You can add a column with the primary keys in your text file, then import it.Note: If you get that error on the first column, make sure your file does not have the BOM. If it has the BOM (3 bytes at the beginning of the file), it will fail on the first row.

1: INSERT failed: datatype mismatch

>     drop table words ;>     CREATE TABLE words (id INTEGER PRIMARY KEY AUTOINCREMENT, name COLLATE NOCASE, rank INT);>     .import file.txt words1|a|02|b|03|c|04|d|05|e|06|f|07|g|0