Import csv into sqlite with autoincrementing primary key

前端 未结 2 1353
深忆病人
深忆病人 2020-12-28 17:27

I am trying to create a table in sqlite that takes data from a csv file and adds an autoincrementing primary key to the first column. Here is the table I am trying to insert

2条回答
  •  被撕碎了的回忆
    2020-12-28 17:38

    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;
    

提交回复
热议问题