From: | Vick Khera <vivek(at)khera(dot)org> |
---|---|
To: | Nicolas Paris <niparisco(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: psql format result as markdown tables |
Date: | 2018-01-14 19:44:00 |
Message-ID: | CALd+dce8buMF2XRQ8qdgvhY5UdADAGh8ri+hW=u+vgeDxWbL-A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)gmail(dot)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
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Dylan Luong | 2018-01-15 00:13:46 | RE: Missing WAL file after running pg_rewind |
Previous Message | Peter J. Holzer | 2018-01-14 17:47:35 | Re: String comparison problem in select - too many results |