Last Updated: February 25, 2016
· carlosefonseca

Export all tables in a SQLite3 db to CSV files

#!/usr/bin/env bash

# obtains all data tables from database
TS=`sqlite3 $1 "SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%';"`

# exports each table to csv
for T in $TS; do

sqlite3 $1 <<!
.headers on
.mode csv
.output $T.csv
select * from $T;



1 Response
Add your response

Worked perfectly. Thank you.

over 1 year ago ·