How to specify data type when importing data from csv to sqlite3

From www.sqlite.org site I can import data from csv file as follows.

sqlite> .mode csv
sqlite> .import data.csv name_table

      

If the table did not exist before, the table is automatically created and the contents of the first line of the input CSV file are used to determine the name of all columns in the table.

But the data type for each column is always TEXT. I want to make some column as INTEGER. How to set data type in csv file.

data.csv
NAME,IMAGE,GENERAL,NUMBER
AAA,img0001.png,"This is Yu favorite. AAA is not a girl.",15
BBB,img0002.png,This is Yu favorite,20
CCC,img0003.png,This is Yu favorite,30

sqlite> .schema
CREATE TABLE name_table(
  "NAME" TEXT,
  "IMAGE" TEXT,
  "GENERAL" TEXT,
  "NUMBER" TEXT
);

      

+3


source to share





All Articles