Search code examples
postgresqlexport-to-csvbatch-processingdatagrip

How to export multiple queries from DataGrip


I have a file that contains multiple select queries.
I run these on a weekly basis to generate internal company reports

For example (these are not the actual queries):

-- Select number of users
SELECT count(id) from users;

-- Select number of active users
SELECT count(id) from users where active = true;

-- Select number of logins this week
SELECT count(id) from users where last_login > current_date - interval '1 week';

--- etc...

Is there a way, in DataGrip, to run all of these queries and export them to csv files?

I am able to run each query and then export the dataset, however, is a time consuming process doing this one by one.


Solution

  • It's possible. Select all queries and then use Execute To Files:

    enter image description here