Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite 3 - Is there a way to export a database file to a tab-delimited text file?

Tags:

linux

sqlite

I currently have a large 15 GB database .db file in my linux EC2 server. I know that SQLite 3 can directly export to a .csv file using this command:

sqlite3 -header -csv ./home/data.db "select * from datafile;" >> out.csv

However, I was wondering if there was an option for exporting a .db file into a tab-delimited text file instead. I looked up and down the documentation for SQLite 3 but only found references to .csv files. Would anyone know anything on how I could do this? Thanks so much!

like image 223
user1398057 Avatar asked Oct 06 '14 21:10

user1398057


1 Answers

Sure:

sqlite3 -header -separator " " ./home/data.db "select * from datafile;" > out.txt

should do it. The contents of " " is the tab character. You can type if from the command line (in bash) by preceeding it with a Ctrl-v.

like image 147
ldav1s Avatar answered Nov 10 '22 01:11

ldav1s