A home of miscellaneous projects by Paul Philippov.


How to dump SQLite DB tables into separate CSV files

Create an .sql file instructing sqlite to export data to csv files with columns organized in particular order

# dump2csv.sql

.mode csv
.headers on

.output categories.csv
select id,name,parent_id,description,created_at,updated_at from categories;

.output items.csv
select id,name,category_id,description,created_at,updated_at from items;


then feed it into sqlite against your database

sqlite3 mydatabase.sqlite3 < dump2csv.sql