This is a small script made to do one thing: take an SQL query from the clipboard and output a CSV file with results.
As a data analyst, part of my job was sending results of ad-hoc queries to a bunch of people on slack. The data warehouse was quite slow, so I had to:
- write a query in DataGrip (or any SQL client)
- execute it
- wait for results
- remember that there was a request for data
- save the results to CSV file (with my mouse)
- send it to the person on Slack who asked for it
With many requests per day, many of them concurrent, this was a problem.
With this tool, I just had to write a query, make sure it works, copy it to clipboard and execute:
vertica-query-paste | slackcat --channel some.person
and not worry about remembering to send it afterwards.I also had an alias in my shell set to
vqp=vertica-query-paste | pv -l
and a bunch of shortcuts for slackcat for people that most often asked for ad-hoc query results.It works with Vertica, but can be generalized to any DB engine that has a CLI client.
Really simple, but probably saved my many hours.