SQLite - adityaskarnik/expense_app GitHub Wiki

Importing json in database

SQLITE3

As sqlite3 only supports only csv, first convert the json file to csv from here. Download and keep the csv

Check installation of sqlite3 is done, else do sudo apt install sqlite3

Connect to database with:

sqlite3 db.sqlite3 #db.sqlite3 is your own database filename
.mode csv
.import data.csv table_name

Provide your own table name and the actual path to the csv file and with .import command you can load all the data from the csv to database with the same existing format of your json

With .tables you can view the newly created table in sqlite With .schema you can view the query for tables creation that will is used Now to view you data has been successfully imported to json, run the query:

SELECT * FROM table_name

Here you will get the output. Now you have successfully imported the json in to sqlite3 database

Exporting to csv

Connect to database with:

sqlite3 db.sqlite3 #db.sqlite3 is your own database filename

Specifying that you need the Column headers also:

.headers on
.mode csv
.output dump.csv
SELECT * FROM table_name;