SQLite Forum

Issue importing csv file to db
I intended to mention one other problem.

When you .import into an existing table, the SQLite shell treats the first line of the file like all the others; it is not specially interpreted as naming the columns.  Your large text file's first line has the same text values you use as column names in the CREATE TABLE statement you showed. Hence, if the .import had no other problems, the first line of the file is treated as mere data. That fails to be imported due to the constraint you have on the first column. This is kind of a happy accident, since you likely did not want it treated as data. But if you intended it to be treated as column headers, that is not happening either.

When you .import into a new table, (one not yet defined), the first line **is** treated as column headers, and the table is created with the names given.  That may lead to an easier solution for you.  It is a simple matter to .import into a temporary table to be created, then copy it (using a SELECT clause as the source) to a table which has all the types and constraints you need.