SQLite to CSV export

Yes, I could have written yet another little Python script to do this, but it turns out there’s a really easy way to export a SQLite database table to a CSV file from the command-line interface.

% sqlite3 databasefile.sqlite
sqlite> .headers on
sqlite> .mode csv
sqlite> .output outputfile.csv
sqlite> select * from table_name;
sqlite> .quit

And that’s it. Couldn’t be easier really.

Hat tip to http://www.sqlitetutorial.net/sqlite-export-csv/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s