A handy data extractor for pasting data from a DataGrip table into SQL

I have found myself running a query, copying some data from the results window, then pasting it into some other query as conditions and then doctoring up the pasted text to be valid *WAY* to many times, so I made a copy of the CSV-Groovy.csv.groovy extractor and I altered it to be able to paste the following:

SELECT foo,bar,baz FROM DUAL;

foo | bar | baz

123 | abc | TRUE

456 | xyz | NULL

 

Copy the first column with the PasteList-Groovy extractor and you get:

123,456

 

Second column:

'abc','xyz'

 

Third column:

TRUE,NULL

 

First and second columns:

(123,'abc'),

(456,'xyz')

 

Hope this helps someone else.  This code was based on JetBrains' CSV-Groovy.csv.groovy script which had no obvious explicit license.  All my rights to this code are transferred to JetBrains and the license for this code is the same as the license for the original script from JetBrains.

https://gist.github.com/deinspanjer/57158b788c7faaeb6658a001b0edb6f2 

Please sign in to leave a comment.