Programmatically run a query and export it as a CSV file in DataGrip
Asked Answered
S

1

6

I am looking to write script in either Python on JavaScript that executes an SQL file query and then saves the results in a CSV file. Bonus points if I can also make it time-bound to run at a specific time.

I have tried looking at the IDE Scripting Console but I can't find any relevant documentation to actually running JavaScript or Python even though it says it's possible.

I'm also open to doing it using the HTTP client and send the query result using a post request.

Anything that can automate the manual labor of clicking through the UI would be hugely appreciated.

Sukhum answered 5/8, 2020 at 20:41 Comment(2)
Were you able to get this done somehow? I am stuck on the same problem.Foretopsail
No, never found a way to do it. Had to run python scriptsSukhum
C
5

In the IntelliJ-based IDEs there is a functionality called execute to file. Is it what you are looking for?

enter image description here

Compatible answered 6/8, 2020 at 15:5 Comment(3)
Thanks for answering! No, I'm looking for something that will both run a query and save it but with out me needing to click through menus in the UI. I'm looking to build a script that essentially automates UI clicks.Sukhum
So, you have your SQL in the query console of DataGrip. You want to PRESS MAGIC BUTTON and with no other UI interactions, you want the CSV file to be created. Am I right?Compatible
I have a few SQL files saved in a folder, I want DG to open each, run them and then save each to a CSV file with one press of a Magic Button. I know that you can run scripts in DG, but it seems like it's so complex/unclearly documented, no one is actually doing it.Sukhum

© 2022 - 2024 — McMap. All rights reserved.