When I import a csv file to sqlite database, it imports number as string to integer column, how can I fix this? A line from my csv file like this:
31,c,BB R
You just need to create the table first with correct types and then the CSV-import will keep this types, because the table already exists.
Here a sample:
create table table1(name TEXT, wert INT);
.mode csv
.separator ";"
.import "d:/temp/test.csv" table1
If you need to delete an imported header-line then use something like this after the import:
delete from table1 where rowid=1;
or use this in case you already did multiple imports into the same table:
delete from [table1] where "name"='name'; -- try to use a name of an INT-column for this.
at the end you can just check the correct import like this:
.header ON
select * from table1 order by wert;