Re: psql format result as markdown tables - Mailing list pgsql-general

From Vick Khera
Subject Re: psql format result as markdown tables
Date
Msg-id CALd+dce8buMF2XRQ8qdgvhY5UdADAGh8ri+hW=u+vgeDxWbL-A@mail.gmail.com
Whole thread Raw
In response to psql format result as markdown tables  (Nicolas Paris <niparisco@gmail.com>)
List pgsql-general
How does this work for you? I use this to get tables to insert into my wiki, which are basically the format you want. I just delete the extra lines I don't want at the end.

vk=> SELECT * FROM (values(1,2),(3,4)) as t;
 column1 | column2
---------+---------
       1 |       2
       3 |       4
(2 rows)

Time: 37.888 ms
vk=> \pset border 2
Border style is 2.
vk=> SELECT * FROM (values(1,2),(3,4)) as t;
+---------+---------+
| column1 | column2 |
+---------+---------+
|       1 |       2 |
|       3 |       4 |
+---------+---------+
(2 rows)

For you it looks like you need to change the "+" to "|" and it will work and delete the first and last lines. I don't know if you can change that with some other \pset setting.

On Sat, Jan 13, 2018 at 4:50 AM, Nicolas Paris <niparisco@gmail.com> wrote:
Hello

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


pgsql-general by date:

Previous
From: "Peter J. Holzer"
Date:
Subject: Re: String comparison problem in select - too many results
Next
From: Dylan Luong
Date:
Subject: RE: Missing WAL file after running pg_rewind