The following command exports the data from the Employees table to a CSV file named employees.csv
.
sqlite3 -header -csv Company.db "SELECT * FROM Employees LIMIT 4" > employees.csv
-header
: Also export the column header name. If you don't want it, don't include in your command.-csv
: Export as CSV mode.Company.db
: Your database filename."SELECT * FROM Employees LIMIT 4"
: Your SQL query.> employees.csv
: Export toemployees.csv
file.
If you check the employees.csv
file, you will see the following output.
firstname,lastname,salary,hired_on "André",Doe,839391.98,2010-12-01 Nikki,Smith,105391.98,2018-11-21 "François",Brown,25391.98,2019-11-21 "Chloé",Anderson,95391.98,1990-09-13