SQLite 3 cheatsheet
SQLite 3: Import, export and backup
6 common SQLite 3 tasks.
Import a CSV file
Load a CSV file into a table, creating the table from the first row if it doesn't exist.
.import --csv data.csv users
Export a query to CSV
Write query results to a CSV file with headers.
sqlite3 -csv -header app.db "SELECT * FROM users;" > users.csv
Dump the database as SQL
Write the schema and data as SQL statements.
sqlite3 app.db .dump > backup.sql
Restore from a SQL dump
Recreate a database from a dump into a new file.
sqlite3 restored.db < backup.sql