Export data in WebStorm
WebStorm has an engine to export and import data in various formats. You can select a predefined format or create your own.
For more information about export and import operations, see the corresponding section.
You can export or copy to the clipboard any result set, table, or view.
Export to a file
To export data to a file, perform one of the following actions:
Right-click a result set, a table, or a view, select Export Data.
Right-click a query and select Export Data to File.
On the toolbar, click the Export Data icon () and select Export to File.
In the Export Data dialog, click Export to File.
Export to a clipboard
Select data in the result set or in the editor and press Ctrl+C.
On the toolbar, click the Export Data icon () and select Copy To Clipboard.
You can select a built-in export format from the list near the Export Data icon (). There are several built-in formats. You can export data as a set of INSERT or UPDATE statements. Also, you can select text formats like CSV, JSON, HTML, Markdown, and other formats (for more information about export options, see Import/Export options.
Before WebStorm 2020.1, if you select the default extractor from the list, you set this extractor as default for the whole IDE. Beginning from WebStorm 2020.1, you set the extractor for a single table. If you open a different table, the extractor defaults to CSV.
Configure an extractor for delimiter-separated values
You can extend the default functionality and create your own format that is based on CSV or any DSV format.
From the Export Data list (), select Configure CSV formats.
In the CSV Formats dialog, click the Add Format icon .
Specify a name of a new format (for example, Confluence Wiki Markup).
Define settings of the format, and click OK.
When the format is created, you can select it in the drop-down list near the Export Data icon ().
Creating any text extractor with scripting
Looking closely at the filename, CSV-Groovy.csv.groovy:
CSV-Groovy is the name of the script.
csv is the extension of the result file.
groovy is the extension of the script.
Scripts are usually located in Scratches and Consoles/Extensions/Database Tools and SQL/data/extractors. Or you can select Go to scripts directory in the extractor menu to navigate there.
Edit an existing extractor or add your own to this folder.
Let’s create an extractor that dumps your data to the CSV format, but only to one row. It can be useful if you are going to paste these values into an IN operator in a WHERE clause.
See the following diff of two scripts: the existing CSV-Groovy.csv.groovy and CSV-ToOneRow-Groovy.csv.groovy.
Consider available context bindings:
These objects are equal when you dump a whole page to a file.
DasTable has two important methods:
Additional information about the API can be found here.
When you create or edit Groovy scripts in WebStorm, and have Groovy installed, coding assistance is available.
Once CSV-ToOneRow-Groovy.csv.groovy is in the folder, you can use the extractor.
Copy these values and paste them into the query.
Here’s another example that is based on SQL-Insert-Statements.sql.groovy. MySQL and PostgreSQL allow using multi-row syntax. To use this type of extractor, create a new SQL-Inserts -MultirowSynthax.sql.groovy file in the scripting folder.
Again, select it in the menu.
See the result in WebStorm:
Feel free to use other generated extractors on GitHub: