From: | Stephen Frost <sfrost(at)snowman(dot)net> |
---|---|
To: | Melvin Davidson <melvin6925(at)gmail(dot)com> |
Cc: | Nicolas Paris <niparisco(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: psql format result as markdown tables |
Date: | 2018-01-13 22:25:11 |
Message-ID: | 20180113222511.GL2416@tamriel.snowman.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Greetings Melvin,
* Melvin Davidson (melvin6925(at)gmail(dot)com) wrote:
> On Sat, Jan 13, 2018 at 4:50 AM, Nicolas Paris <niparisco(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-01-13 23:12:58 | Re: psql format result as markdown tables |
Previous Message | Stephen Frost | 2018-01-13 22:19:58 | Re: psql format result as markdown tables |