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
sqlite3


source to share


No one has answered this question yet

See similar questions:

7
How to import csv file into sqlite with correct datatypes

or similar:

234
How do I set Sqlite3 to be case insensitive when comparing strings?
3
Importing .csv file into sqlite3 db table
2
How can I use a CSV file to update all column values ​​in a table?
1
SQLite: import floating point data from CSV file as numeric using sqlite3.exe utility
1
How can I control how SQLite3 imports the CSV file?
0
how to insert values ​​from csv into sqlite3 using python
0
How can I import a CSV file into sqlite3 in Python without knowing in advance how many columns?
0
Python importing CSV file into sqlite3 removes replication
0
error.import for CSV SQLite3
0
SQLite3: Failure to Import CSV on Mac



All Articles
Loading...
X
Show
Funny
Dev
Pics