Aqua Data Studio Macro possible?

844 views Asked by At

is it possible to define some kind of macro/scripts in Aqua Data studio?

Basically, what I want to do: I have a folder containing several SQL-queries named xyz.sql, I want to run all of them and save them as xyz.csv

Is this somehow possible?

Thanks very much!

1

There are 1 answers

8
tariq On BEST ANSWER

Aqua Data Studio has a feature called FluidShell which is an integrated shell, where you can use FluidShell commands to execute SELECT query and write it to File.

FluidShell Introduction
FluidShell Commands

A few of the command which would be useful to achieve your task would be
Executing SQL
[Source][4]

[4]: http://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Documentation15/page/289/source

To test I created 2 tables named foo and bar under SQL Server database named Northwind under a schema named dbo and inserted a few records. Next, I created a file named xyz.sql and put below 2 lines and saved the file.

sqlexport -f csv -d Northwind -s dbo foo -o /Users/tariq/Desktop/stack1.csv
sqlexport -f csv -d Northwind -s dbo bar -o /Users/tariq/Desktop/stack2.csv

Then opened a fluidshell and used the source command source xyz.sql. Now the files were exported successfully to 2 files.

Two things which I can think of are :
A.) Contents in query.sql is SELECT * FROM dbo.Orders where ShipVia > 2 @
Then I use the source combined with tee to get the results with
source query.sql | \tee result.txt

B.) Contents in query2.sql is as below
select * from dbo.Orders where ShipVia > 2
\go > mydata.txt
Then at the FluidShell prompt use source query2.sql