From: Julian Assange <proff@suburbia.net>
Date: Wed, 28 Feb 1996 15:38:22 +1100 (EST)
Subject: Re: [PG95]: psql/monitor/libpq enhancements (now does html3, alignment, pipes etc)

> Yippie, shell access to pg95, bravo, bravo.  Was there an option to
> turn off all prompts and output from psql except for query results, so
> I could do things like:
> 
> 	echo "select * from foo" | psql | netscape /proc/self/fd/0
> 
> The tab-separated output shold quote tabs as \t and newlines as \n to
> be a lot more robust.  I would also ask for one more output format,

At the moment my code escapes whatever the field separater character is,
I'm not sure how tabs and so forth are handled, but you suggestion 
doesn't go astray.

bash$ echo "select username, uid from users where uid%300=0;"|psql -T "border=1" -H users| netscape /proc/self/fd/0
<table border=1><caption align=high>Retrieved 3 tuples * 2 fields</caption>
<tr><th align=left>username</th><th align=right>uid</th></tr>
<tr><td align=left>jbray</td><td align=right>2400</td></tr>
<tr><td align=left>pitch</td><td align=right>2100</td></tr>
<tr><td align=left>brad</td><td align=right>3600</td></tr>
</table>

Is the command you are probably looking for. notice the trailing ";". You can
use  -c SQL_statement as well (and need not appened a ; then.. also you can
turn on one-query-per-line mode)

Unfortunately this won't work, due to some errors I made with the getopt
line in src/bin/psql.c vis -T and -H (groan). You will need to change it
to the following (there is only one getopt() call in the code):

1141:  while ((c = getopt(argc, argv, "Aa:c:d:ef:F:lh:Hnso:p:qStT:x")) != EOF) {

> which is rdb perl script format.  This is tab separated except the
> first lines are fieldnames and the second line is fieldwidths and
> types, S for string and N for numeric.  The format looks like:
> 
> 	field1	field2	field3
> 	10S	9N	10S
> 	foo	12345	bar
> 	baz	456	quux

Looks easy to impliment. I'll put it in the next patch.

- -- 
"I mean, after all;  you have to consider we're only made out of dust.  That's
 admittedly not  much  to  go  on  and  we  shouldn't  forget  that.  But even
 considering, I mean it's sort of a bad beginning, we're not doing too bad. So
 I personally have faith that even in this lousy situation we're faced with we
 can make it. You get me?" - Leo Burlero/PKD
+---------------------+--------------------+----------------------------------+
|Julian Assange RSO   | PO Box 2031 BARKER | Secret Analytic Guy Union        |
|proff@suburbia.net   | VIC 3122 AUSTRALIA | finger for PGP key hash ID =     |
|proff@gnu.ai.mit.edu | FAX +61-3-98199066 | 0619737CCC143F6DEA73E27378933690 |
+---------------------+--------------------+----------------------------------+

