byoycg
Last Updated: February 25, 2016
·
7.721K
· carlosefonseca
7604a48be008a79e1ee10be31ca95220

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;
!

done

Gist

Say Thanks
Respond

1 Response
Add your response

17126
Fd3570a7da4cc9e159b4bda5b66f5664

Worked perfectly. Thank you.

over 1 year ago ·
Filed Under