pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedpsql \conninfo in tabular form?
2+ messages / 2 participants
[nested] [flat]
* psql \conninfo in tabular form?
@ 2023-03-07 17:58 Ron <ronljohnsonjr@gmail.com>
2023-03-07 19:07 ` Re: psql \conninfo in tabular form? Erik Wienhold <ewie@ewie.name>
0 siblings, 1 reply; 2+ messages in thread
From: Ron @ 2023-03-07 17:58 UTC (permalink / raw)
To: pgsql-general
v13.10
Instead of a sentence like this:
You are connected to database "postgres" as user "postgres" via socket in
"/var/run/postgresql" at port "5433".
I'd rather have something tabular like:
keyword | value
------------+-----------------------
database | postgres
user | postgres
host | /var/run/postgresql
port | 5433
Running psql with the -E option didn't help. There's a github project named
ibarwick/conninfo which looked useful, but it seems to only parse connection
strings.
--
Born in Arizona, moved to Babylonia.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: psql \conninfo in tabular form?
2023-03-07 17:58 psql \conninfo in tabular form? Ron <ronljohnsonjr@gmail.com>
@ 2023-03-07 19:07 ` Erik Wienhold <ewie@ewie.name>
0 siblings, 0 replies; 2+ messages in thread
From: Erik Wienhold @ 2023-03-07 19:07 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general
> On 07/03/2023 18:58 CET Ron <ronljohnsonjr@gmail.com> wrote:
>
> v13.10
>
> Instead of a sentence like this:
> You are connected to database "postgres" as user "postgres" via socket in
> "/var/run/postgresql" at port "5433".
>
> I'd rather have something tabular like:
> keyword | value
> ------------+-----------------------
> database | postgres
> user | postgres
> host | /var/run/postgresql
> port | 5433
Define variable conninfo with the query in ~/.psqlrc:
\set conninfo 'select * from (values (''database'', current_database()), (''user'', session_user), (''host'', coalesce(inet_server_addr()::text, current_setting(''unix_socket_directories''))), (''port'', coalesce(inet_server_port()::text, current_setting(''port'')))) t(keyword, value);'
And run it like that:
postgres=# :conninfo
keyword | value
----------+-----------------
database | postgres
user | ewie
host | /run/postgresql
port | 5432
(4 rows)
--
Erik
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-03-07 19:07 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 17:58 psql \conninfo in tabular form? Ron <ronljohnsonjr@gmail.com>
2023-03-07 19:07 ` Erik Wienhold <ewie@ewie.name>
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