From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | David Fetter <david(at)fetter(dot)org> |
Cc: | Vik Fearing <vik(at)postgresfriends(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal \gcsv |
Date: | 2020-03-01 12:34:23 |
Message-ID: | CAFj8pRDqgii0a0d6KSw9k8m-cj-vXhiBFpfWC4W6uJ9LR+e3Yw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
so 29. 2. 2020 v 18:06 odesílatel David Fetter <david(at)fetter(dot)org> napsal:
> On Sat, Feb 29, 2020 at 11:59:22AM +0100, Pavel Stehule wrote:
> > so 29. 2. 2020 v 11:34 odesílatel Vik Fearing <vik(at)postgresfriends(dot)org>
> > napsal:
> >
> > > On 29/02/2020 06:43, Pavel Stehule wrote:
> > > > Hi
> > > >
> > > > I would to enhance \g command about variant \gcsv
> > > >
> > > > proposed command has same behave like \g, only the result will be
> every
> > > > time in csv format.
> > > >
> > > > It can helps with writing psql macros wrapping \g command.
> > > >
> > > > Options, notes?
> > >
> > > But then we would need \ghtml and \glatex etc. If we want a shortcut
> > > for setting a one-off format, I would go for \gf or something.
> > >
> > > \gf csv
> > > \gf html
> > > \gf latex
> > >
> >
> > usability of html or latex format in psql is significantly lower than csv
> > format. There is only one generic format for data - csv.
>
> Not exactly. There's a lot of uses for things along the lines of
>
> \gf json
> \gf yaml
>
> I'd rather add a new \gf that takes arguments, as it seems more
> extensible. For example, there are uses for
>
I implemented \gf by Vik's proposal
> \gf csv header
>
> if no header is the default, or
>
> \gf csv noheader
>
It is little bit hard (although it looks simply).
The second option of this command can be file - and it reads all to end of
line. So in this case a implementation of variadic parameters is difficult.
Motivation for this patch is a possibility to write macros like
postgres=# \set gnuplot '\\g | gnuplot -p -e "set datafile separator
\',\'; set key autotitle columnhead; set terminal dumb enhanced; plot
\'-\'with boxes"'
postgres=# \pset format csv
postgres=# select i, sin(i) from generate_series(0, 6.3, 0.05) g(i) :gnuplot
with \gf csv I can do almost what I need.
\set gnuplot '\\gf csv | gnuplot -p -e "set datafile separator \',\'; set
key autotitle columnhead; set terminal dumb enhanced; plot \'-\'with
boxes"'
> if header is the default.
>
> Best,
> David.
> --
> David Fetter <david(at)fetter(dot)org> http://fetter.org/
> Phone: +1 415 235 3778
>
> Remember to vote!
> Consider donating to Postgres: http://www.postgresql.org/about/donate
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ranier Vilela | 2020-03-01 12:52:47 | Re: Broken resetting of subplan hash tables |
Previous Message | Pavel Stehule | 2020-03-01 12:29:19 | Re: proposal \gcsv |