TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQLite Export

SQLite Export with history, features, advantages, installation, commands, syntax, datatypes, operators, expressions, databases, table, crud operations, clauses, like, glob, limit, and clause, advance sqlite

<< Back to SQLITE

SQLite Export

SQLite 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 file

Let'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:

Sqlite Export 1
.header on
.mode csv
.once /Users/TheDeveloperBlog1/Desktop/sqlite/student.csv
SELECT * FROM STUDENT; 
Sqlite Export 2

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:

Sqlite Export 3

It is having the same data of SQLite STUDENT table.

Sqlite Export 4

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:

  • On Windows, use .system followed by the file name.
  • On Mac, use .system open followed by the file name.
  • On Linux and Unix systems, use .system followed by the name of the program to open the file, followed by the file name. For example, .system libreoffice /file.csv

Next TopicJava SQLite




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf