From: Stephen Frost <sfrost@snowman.net>
To: Melvin Davidson <melvin6925@gmail.com>
Cc: Nicolas Paris <niparisco@gmail.com>
Cc: pgsql-general@postgresql.org >> PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: psql format result as markdown tables
Date: Sat, 13 Jan 2018 17:25:11 -0500
Message-ID: <20180113222511.GL2416@tamriel.snowman.net> (raw)
In-Reply-To: <CANu8Fiz5gf1j6FpF+dcrftZdHz83VAAqLEaAbX0H+o0feckCcQ@mail.gmail.com>
References: <20180113095053.dlf6mj32wxqqgcgk@gmail.com>
<CANu8Fiz5gf1j6FpF+dcrftZdHz83VAAqLEaAbX0H+o0feckCcQ@mail.gmail.com>
Greetings Melvin,
* Melvin Davidson (melvin6925@gmail.com) wrote:
> On Sat, Jan 13, 2018 at 4:50 AM, Nicolas Paris <niparisco@gmail.com> wrote:
> > I wonder if someone knows how to configure psql to output results as
> > markdown tables.
> > Then instead of :
> >
> > SELECT * FROM (values(1,2),(3,4)) as t;
> > column1 | column2
> > ---------+---------
> > 1 | 2
> > 3 | 4
> >
> > Get the result as :
> > SELECT * FROM (values(1,2),(3,4)) as t;
> > | column1 | column2|
> > |---------|--------|-
> > | 1 | 2|
> > | 3 | 4|
> >
> > Thanks by advance
>
> *A. You have not graced us with PostgreSQL version and O/S*
While it can make a difference, it doesn't in this case, as far as I can
tell. You can see the list of formats supported by each version of
PostgreSQL by going to:
https://www.postgresql.org/docs/current/static/app-psql.html
and then you can walk backwards through the various releases.
> *B. Your two examples appear exactly the same.*
Not true, actually, if you look carefully you'll see that there's a set
of pipes down the left-hand side, and pipes all down the middle (instead
of a '+' on the linebreak between the header and the data). Those kinds
of differences are what would make having an actual markdown output
format for psql particularly useful as, otherwise, you have to
hand-massage it or use another tool.
> *C. Have you looked at https://donatstudios.com/CsvToMarkdownTable
> <https://donatstudios.com/CsvToMarkdownTable; ?*
That might be helpful in this case, though it would require sending data
to an 3rd party, which might not be ideal. There's a number of
csv2markdown tools out there though which could be installed locally.
Not quite as nice as having the support in psql for it though.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: sfrost@snowman.net, melvin6925@gmail.com, niparisco@gmail.com
Subject: Re: psql format result as markdown tables
In-Reply-To: <20180113222511.GL2416@tamriel.snowman.net>
References: <20180113095053.dlf6mj32wxqqgcgk@gmail.com> <CANu8Fiz5gf1j6FpF+dcrftZdHz83VAAqLEaAbX0H+o0feckCcQ@mail.gmail.com> <20180113222511.GL2416@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox