Export CSV from command line

Having trouble getting started? Check here...
Post Reply
mriemann
Posts: 2
Joined: Mon Feb 12, 2018 11:04 am

Export CSV from command line

Post by mriemann » Mon Feb 12, 2018 11:14 am

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?

Dave
Site Admin
Posts: 361
Joined: Sun Nov 27, 2005 7:19 pm

Re: Export CSV from command line

Post by Dave » Mon Feb 12, 2018 2:38 pm

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.

mriemann
Posts: 2
Joined: Mon Feb 12, 2018 11:04 am

Re: Export CSV from command line

Post by mriemann » Mon Feb 12, 2018 3:58 pm

I think this solution will work for our purpose.

Thank you for your quick reply!

Dave
Site Admin
Posts: 361
Joined: Sun Nov 27, 2005 7:19 pm

Re: Export CSV from command line

Post by Dave » Tue Apr 10, 2018 4:04 pm

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

Post Reply