Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaUEm-0003GY-R7 for pgsql-general@arkaria.postgresql.org; Sat, 13 Jan 2018 22:25:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaUEm-0007np-16 for pgsql-general@arkaria.postgresql.org; Sat, 13 Jan 2018 22:25:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eaUEl-0007nJ-MK for pgsql-general@lists.postgresql.org; Sat, 13 Jan 2018 22:25:15 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eaUEi-0005QP-KN for pgsql-general@postgresql.org; Sat, 13 Jan 2018 22:25:14 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 93F355F7A2; Sat, 13 Jan 2018 17:25:11 -0500 (EST) Date: Sat, 13 Jan 2018 17:25:11 -0500 From: Stephen Frost To: Melvin Davidson Cc: Nicolas Paris , "pgsql-general@postgresql.org >> PG-General Mailing List" Subject: Re: psql format result as markdown tables Message-ID: <20180113222511.GL2416@tamriel.snowman.net> References: <20180113095053.dlf6mj32wxqqgcgk@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="A7YYZHk1c+9kt+kv" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --A7YYZHk1c+9kt+kv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Greetings Melvin, * Melvin Davidson (melvin6925@gmail.com) wrote: > On Sat, Jan 13, 2018 at 4:50 AM, Nicolas Paris 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 > ?* 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 --A7YYZHk1c+9kt+kv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaWodHAAoJEO1sijiDR2RVdVsP/0wDILGdPj0LJjZnaNqGIXrl KGVbdKvZoXOsMONNVfPiET9ara4gZc4RhlMxr4p+LKOVUTX50q9/8pVjLFIA6TT0 0mwpbCk9yYfRIaLXz2vFQ5XFpxgvewjwjXqa5cC78fh70BurnBHS/CcUL+KjVDNf DrPCrOm9Aws3pLocg2klH0EeFzDLqvNMxI5qZ2VloHW+1dF2r00AhTx4ZCCsH9cX +s8kO4MFOucE0Hqq4zQaiVa5PizkJu3IY+D6ads/yBQNX3vmq/Oc/Bdgvv6uP6g/ BFvFuohKHaxqi2/bJ2omLiiuNMvTXzSM+WooZJ6zmgtHJ8limhGb6hIzbY7Qh0r0 +aUgQXMERcgiFLSLsjVFE0p12dZAoHJ0IfWS9SNwlifNs2VyLrtvlwlmlzMBLHJf S0zvwtG7zgGkSNpIKckWN0jfsFTolMy4mHPmcgPLz0ACFR2KjZ5wPBE+M1T5YJ+6 N+QZkXnx8b1UEJf+mOD50VZUqJkFX0p6A+NzAllRA5JGm/rVVof+wBPdmwl75LPw SI3/lH8cCxruLd/UB6Zwcnf2K4aHg4oWGeXESglZxnnBRcz0YyGb/mn5RLSjfFaA BX/149XKzUP6KBXSshY//8KVAOLx30CCxz12b5H30ULf570/FxSG8lvPCiN5WO2r K8G7RTNhAKYpfn5kvtKx =h1ml -----END PGP SIGNATURE----- --A7YYZHk1c+9kt+kv--