Page 1 of 1

Export CSV from command line

Posted: Mon Feb 12, 2018 11:14 am
by mriemann
We are currently working on automated execution of Rel queries.

In the graphical interface of Rel, it is possible to export the results of a query as a CSV file.

Does the RelDBMS command line tool support CSV as well?

Re: Export CSV from command line

Posted: Mon Feb 12, 2018 2:38 pm
by Dave
mriemann wrote:
Mon Feb 12, 2018 11:14 am
Does the RelDBMS command line tool support CSV as well?
Not directly, no. You could create a script named, say, S_TO_CSV.rel with the following contents:

Code: Select all

FOR S ORDER(ASC SNAME);
	WRITELN S# || "," || SNAME || "," || STATUS || "," || CITY;
END FOR;
Then invoke it with something like...

Code: Select all

./RelDBMS < S_TO_CSV.rel > output.csv
...to obtain output in CSV format, along with the Rel DBMS startup and shutdown text.

It sounds like something that would be useful, so I'll think about how this could be better automated.

Re: Export CSV from command line

Posted: Mon Feb 12, 2018 3:58 pm
by mriemann
I think this solution will work for our purpose.

Thank you for your quick reply!

Re: Export CSV from command line

Posted: Tue Apr 10, 2018 4:04 pm
by Dave
In the latest 3.012 update, I've provided a command-line flag -- -q -- to silence the various startup and shutdown messages. For example:

Code: Select all

./RelDBMS -q < S_TO_CSV.rel > output.csv