Summary: in this tutorial, you will learn how to export SQLite database to a CSV file.
The database files that are created by SQLite are given the.sqlite file extension and can be used to create customer lists, inventory databases and other database information. The.sqlite file extension is also used by the Mozilla Firefox Internet browser. The read.csv.sql function contains three parts: the name of the csv files that are to be read; an sql query which, among other things, gives the names of the tables to be created; and the name of the database into which the data are imported. This time, the data are imported into Test1.sqlite. R and SQLite: Part 1. November 18, 2012.
There are several ways to dump data from an SQLite database to a CSV file.
Export SQLite Database to a CSV file using sqlite3 tool
SQLite project provides you with a command-line program called sqlite3 or sqlite3.exe on Windows. By using the sqlite3 tool, you can use the SQL statements and dot-commands to interact with the SQLite database.
To export data from the SQLite database to a CSV file, you use these steps:
- Turn on the header of the result set using the
.header
on command. - Set the output mode to CSV to instruct the sqlite3 tool to issue the result in the CSV mode.
- Send the output to a CSV file.
- Issue the query to select data from the table to which you want to export.
The following commands select data from the
customers
table and export it to the data.csv
file.>sqlite3-header-csvc:/sqlite/chinook.db'select * from tracks;'>tracks.csv |
If you have a file named
query.sql
that contains the script to query data, you can execute the statements in the file and export data to a CSV file.