Re: Who am I? Where am I connected?

From: Erik Wienhold <ewie(at)mailbox(dot)org>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Who am I? Where am I connected?
Date: 2022-05-18 10:29:34
Message-ID: 541270671.1136671.1652869774367@office.mailbox.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Dominique,

you can use \conninfo in psql to show the database, user, host (or socket in my example), and port:

ewie(at)desktop ~ $ psql test
Null display is "".
psql (14.3)
Type "help" for help.

test=# \conninfo
You are connected to database "test" as user "ewie" via socket in "/run/postgresql" at port "5432".

- Erik

> On 18/05/2022 12:07 Dominique Devienne <ddevienne(at)gmail(dot)com> wrote:
>
>
> LibPQ has various defaults for the host, user, and DB name.
> There's also the password file, the service file and service name.
> In the example below, I can connect with a "naked" psql invocation.
>
> Once connected, can I find out all aspects of the connection string?
> Or where they came from, like a pgpass.conf or service file?
>
> How to get the host, port, db name once connected?
> SHOW and pg_settings does not appear to be it, at first glance.
>
> Thanks, --DD
>
> c:\Users\ddevienne>psql
> psql (12.1, server 14.2)
> WARNING: psql major version 12, server major version 14.
> Some psql features might not work.
> WARNING: Console code page (437) differs from Windows code page (1252)
> 8-bit characters might not work correctly. See psql reference
> page "Notes for Windows users" for details.
> Type "help" for help.
>
> ddevienne=>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ganesh Korde 2022-05-18 10:30:21 Re: Who am I? Where am I connected?
Previous Message Dominique Devienne 2022-05-18 10:07:47 Who am I? Where am I connected?