Re: csv format for psql

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: David Fetter <david@fetter.org>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Daniel Verite <daniel@manitou-mail.org>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2018-03-07T19:04:05Z
Lists: pgsql-hackers
>>   psql --csv -c 'TABLE foo' > foo.csv
>>
>> With a -c to introduce the command.
>
> This seems pretty specialized.  If we're adding something new, how about
>
>    psql --format=csv -o foo.csv -c 'TABLE foo'
>
> Or we could stick with:
>
>    psql -P format=csv -o foo.csv -c 'TABLE foo'

Currently "-P format=csv" uses the unaligned formating separators, i.e. 
'|' is used. I was suggesting that a special long option could switch 
several variables to some specific values, i.e.

   --csv

Would be equivalent to something like:

   -P format=csv -P fieldsep=, -P recordsep=\n (?) -P tuples_only=on ...

I.e. really generate some csv from the data in just one option, not many.

But this is obviously debatable.

-- 
Fabien.


Commits

  1. Add CSV table output mode in psql.

  2. Reorganize format options of psql in alphabetical order

  3. Complete TODO item: