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).
Connect to database.
Write and execute SQL query (SELECT Statement).
Export data to CSV format.
Open the exported CSV data in LibreOffice Calc.
1- Connect to database.
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.
- From the connection dialog choose SQLite from the database type list.
Use browse button to set the database location.
- Press the connect button.
The connection dialog will disappear.
- Open a new Query tool.
Press the SQL button the second button on the toolbar.
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.
- Press in the Result tab (The tan next to the summery tab) to display the SELECT statement result in a grid.
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.
- Set the file name and location, then press Save to save the exported data to the specified path.
The following image shows the exported CSV 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.
The following image displays the exported data opened in a LibreOffice Calc.
You can learn more about Sohag Builder SQL Tool from this tutorial.