Re: dumping a password-protected db from a perl script or a binary

From: Artur Pietruk <arturp(at)plukwa(dot)pdi(dot)net>
To: dima <_pppp(at)mail(dot)ru>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: dumping a password-protected db from a perl script or a binary
Date: 2002-11-04 15:12:05
Message-ID: 20021104151205.GK3354@yoda.plukwa.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Mon, Nov 04, 2002 at 04:32:38PM +0300, dima wrote:
> How can i dump a password-protected database using perl (DBI or pg) or C
> (using libpq)? I can't pass the password to pg_dump utility (I was
> trying to pass it via tty also) when running system() from perl.

Isn't example below something like what you are trying to do:

====8<====
#include <stdio.h>
#include <stdlib.h>

int main(void) {
system("export PGDATABASE=\"test\"; export PGPASSWORD=\"test\"; export PGUSER=\"test\"; psql");

exit(0);
}
====8<====

? Here psql should connect to db 'test' as user 'test', password
'test'. Check if it works with pg_dump.

I hope that helps! BTW - there are also other ways to do that...
Check docs of your pg version. $PGPASSWORD is deprecated.

Best regards,
--
--- Artur Pietruk, arturp(at)plukwa(dot)net

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message dima 2002-11-04 15:18:46 Re: dumping a password-protected db from a perl script or
Previous Message Eric Comeau 2002-11-04 15:06:59 Re: HA for high insert volume