Export Qyery Result To CSV

In this tutorial you will learn how to use Sohag Builder to export SQL query result to CSV format, which is very useful to exchange data between many applications as an example to view or edit the data from spreadsheet applications like MS Excel or LibreOffice Calc .

This tutorial uses SQLite version of chinook database, you can download it from here.

You may follow the same steps using any other  supported database (PostgreSQL, MariaDB, MySQL).

  1. Connect to database.

  2. Write and execute SQL query (SELECT Statement).

  3. Export data to CSV format.

  4. Open the exported CSV data in LibreOffice Calc.

1- Connect to database.

Tip

You can open SQLite database from recent files, if you have opened it recently.

Hit connect button (first button in the toolbar), or use file menu to connect to database.

Sohag Builder connect to database

Sohag Builder connect to database

  • From the connection dialog choose SQLite from the database type list.

Use browse button to set the database location.

sohag builder connect to sqlite database

  • Press the connect button.

The connection dialog will disappear.

sohag builder database info

  • Open a new Query tool.

Press the SQL button the second button on the toolbar.

Sohag Builder open a new Query Tool to execute sql queries

2- Write and execute SQL query (SELECT Statement).

  • Now write the following query in the SQL editor.
  • Press Execute button or F5 to execute the query.

 

Sohag Builder Executing Query In Query Tool

 

  • Press in the Result tab (The tan next to the summery tab) to display the SELECT statement result in a grid.

 

Sohag Builder SELECT statment result

 

 

 

 

Note

 Since Sohag Builder supports many queries at the same time, you must open the result tab of the specified query you want to export first .

 

 

3- Export data to CSV format.

  • Press Export button to open the export dialog.
  • You can change the CSV Options from the lists if you would like, here I'll the default options.
  • Press Export button to proceed.

 sohag builder export sql select query csv formt

 

  • Set the file name and location, then press Save to save the exported data to the specified path.

 sohag builder export sql select query csv formt

The following image shows the exported CSV data in gedit text editor.

csv exported data in gedit text editor

 

4- Open the exported CSV data in LibreOffice Calc.

  • Open the file using LibreOffice Calc.
  • In Text Import dialog set the correct options as you specified in the export process.
  • Press Ok to view the data.

Opening CSV data using libreoffice calc (spreedsheet)

 

The following image displays the exported data opened in a LibreOffice Calc.

Opening CSV data using libreoffice calc (spreedsheet)

 

Tip

You can learn more about Sohag Builder SQL Tool from this tutorial.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
4 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Verion
v1.0