C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
SQLite ExportSQLite facilitates you to export data from SQLite database to CSV file. You can export the whole table or less according to your query. .once command is used to export data to a CSV file followed by the file path/name where you want to write the file. SQLite Table to CSV fileLet's see an example which will export all the contents of the STUDENT table to a CSV file: The STUDENT table has the following data: .header on .mode csv .once /Users/TheDeveloperBlog1/Desktop/sqlite/student.csv SELECT * FROM STUDENT; Code explanation: .header on: It specifies that headers are enabled. This is optional. If you disable headers, the CSV file simply won't contain any data. .mode csv: It specifies that CSV mode is enabled. .once: It specifies that the output to be written to the CSV file and next is the exact location. After execution of the above code, a CSV file is created on the specified location: It is having the same data of SQLite STUDENT table. How to open CSV file automatically:.system command is used to automatically open the CSV file. For example: The following command open the CSV file automatically in Windows: .system /Users/TheDeveloperBlog1/Desktop/sqlite/student.csv This code may be changed according to operating system:
Next TopicJava SQLite
|