Re: libpq analog of \c

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: libpq analog of \c
Date: 2026-10-05 06:35:09
Message-ID: 65b18907e04e181eca7166e49bfa48314d6d31d3.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 2026-10-04 at 23:09 -0700, Igor Korot wrote:
> What do issue in the libpq interface to
> select the current database?

You cannot select the current database. A database connection remains
connected to the same database for the entire time of the connection.
You'll have to do what psql does: connect to the second database, and
if that succeeds, disconnect from the first one.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carl.Weierstrass 2026-10-05 08:26:55 bug or feature
Previous Message David G. Johnston 2026-10-05 06:28:05 Re: libpq analog of \c