Welcome folks today in this blog post we will be importing csv file
data inside sqlite table
and database in command line. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the below library using the pip
command as shown below
pip install csv_to_sqlite
And after that you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 |
import csv_to_sqlite # all the usual options are supported options = csv_to_sqlite.CsvOptions(typing_style="full", encoding="windows-1250") input_files = ["data.csv"] # pass in a list of CSV files csv_to_sqlite.write_csv(input_files, "output.sqlite", options) |
And now we need to make the data.csv
file and copy paste the following code
data.csv
1 2 3 4 5 |
name,age,country john,24,india kim,45,new zealand austin,67,USA trent,78,UK |
python app.py
And now if you view the output.db
inside the sql
database viewer as shown below