I love working with Datagrip and I try to use and learn new functionalities whenever is possible. Plugins and Live Templates made my life much easier (especially with repetitive tasks). One annoying task I was not able to automate was to convert the result of a query to the Jira format (the one with | and ||), but like some bumper stickers say be the change you want to see: so I wrote a script for that.
I am not an expert here, but many things happening in Datagrip can be controlled via Groovy or Closure scripts, so I had just to see if there was already an export script somewhere and try to modify it.
Luckily there are already multiple export formats as groovy scripts and it is quite easy to modify them. I went with the CSV-Groovy.csv.groovy one, I copied it and started modify it:
The script (below) is quite simple and works quite well. The only thing I was not able to achieve was to export the row headers having transposed data.
You can also download my script and copy it into the script folder. Where is the script folder? Just click on "Go to Scripts Directory" on the export menu and you are there.
Once you have the script in your folder, just select the export format, select on the data and copy them. Your data are now in the Jira tabular format.
A stupid query:
select 1 a_number, 'a' a_letter
union all
select 2 a_number, 'b' a_letter
union all
select 3 a_number, 'c' a_letter
union all
select 4 a_number, 'd' a_letter
;
My export:
||A_NUMBER||A_LETTER||
|1|a|
|2|b|
|3|c|
|4|d|
And the transposed export:
|1|2|3|4|
|a|b|c|d|
I hope this script can serve you well like it served me in the past couple of years. Feel free to ping me for any feedback.