You can import a CSV file into SQLite table by using sqlite3 tool and .import command. This command accepts a file name, and a table name.
Here, file name is the file from where the data is fetched and the table name is the table where the data will be imported into. In the absence of the table, it will create the table automatically according to the data in CSV file.
CSV file to SQLite table
Let's take an example where we import the content of a CSV file to a table that doesn't exist currently. Let's name it "EMPLOYEE". It will create a table based on the data of CSV file.
Note: .mode csv is used before .import to prevent the command-line utility from trying to interpret the input file text as some other format.
Now check if the table is created:
You can see that EMPLOYEE table is created. Now check the data in EMPLOYEE table:
Note: .mode column is used before SELECT statement to show the data in tabular form and specifies the columns.