SQLite - Import CSV file

By xngo on July 21, 2019

Importing CSV file into SQLite database is easy. First, ensure that the first line from the CSV file contains the column names. Then, from the SQLite console, you simply need to define the .separator and then fire the .import commands. Here is a example where I import myfile.csv into mytable in the my.db database file.

>sqlite3 my.db
sqlite> .separator ','
sqlite> .import myfile.csv mytable
sqlite> 

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.