Re: Providing the password to psql from a script

From: Richard Huxton <dev(at)archonet(dot)com>
To: Willem Herremans <willem(dot)herremans(at)belgacom(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Providing the password to psql from a script
Date: 2004-06-02 08:28:52
Message-ID: 40BD8FC4.50108@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Willem Herremans wrote:
> I am developing a client application for postgreSQL in Tcl/Tk (see
> http://gborg.postgresql.org/project/pfm ).
>
> It mainly uses PgTcl or pgintcl. I don't have any problems with those,
> but I am also trying to call psql from my application for SQL statements
> typed directly by the user.
>
> I have used the Tcl command
>
> set psqlChannel [open "|psql $dbname" RDWR]
>
> to create a channel that effectively becomes the input/output channel
> for psql. By writing to that channel, SQL statements are sent to psql,
> by reading from that channel, the results are received from psql.
>
> That works fine, as long as psql does not prompt for a password. The
> problem is that psql does not use this channel for prompting for or
> reading the password. Instead, the password is prompted for on, and read
> from, the terminal from which the tcl application was started and that
> is not what I want, because the Tcl application has already received the
> password from the user. It is, as if psql does not use stdout and stdin
> for the password.

You need to look in the libpq section of the manuals. There is a
PGPASSWORD environment variable, but that is deprecated. The preferred
method is to create a ~/.pgpass file containing password information.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Schoen 2004-06-02 08:36:47 Re: ORDER BY with plpgsql parameter
Previous Message Richard Huxton 2004-06-02 08:23:26 Re: Dynamic SQL