Re: database name. - Mailing list pgsql-general

From Alfred Perlstein
Subject Re: database name.
Date
Msg-id 20001107192642.O5112@fw.wintelcom.net
Whole thread Raw
In response to database name.  (Limin Liu <limin@pumpkinnet.com>)
List pgsql-general
* Limin Liu <limin@pumpkinnet.com> [001107 19:11] wrote:
> Hi,
>
> I am new in PostgreSQL and have a simple question:
> Is there any way we can find out which db the current client is working
> with?
>
> In psql, the prompt tells us the current open db, but I may need to
> access that information in a C client on the fly with may db opened.  I
> wonder if this is possible?

Yes, please check the docs:


    PQdb Returns the database name of the connection.

    char *PQdb(const PGconn *conn)

    PQdb and the next several functions return the values established at connection. These values are fixed for the
life
    of the PGconn object.

It's described in the 'libpq' section of the programmer's manual.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

pgsql-general by date:

Previous
From: Christian Setzkorn
Date:
Subject: application(s) ???
Next
From: Tom Lane
Date:
Subject: Re: PGBUFFERS