Re: execute pg_dump via python

From: Andy <nospam(at)noplace(dot)com>
To: Garry Saddington <garry(at)schoolteachers(dot)co(dot)uk>
Subject: Re: execute pg_dump via python
Date: 2007-10-25 14:23:33
Message-ID: 4720A6E5.2030807@noplace.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Garry Saddington wrote:
> I am using zope on windows with an external python method to backup my
> database. I am struggling to run the following command:
>
> pg_dump.exe database > file
>
> I have tried using os.popen - no luck
> and also subprocess.Popen.
>
> eg:
> import subprocess
>
> subprocess.Popen(['c:/dir/dir/pg_dump.exe','database','>','c:/dir/dir/output
> file'])
>
> The command string works perfectly in a terminal. Does anyone know how I
> should be doing this? I get no errors or traceback when I try the method
> through Zope.
>
> regards
> garry

the redirect operation '>' is done by cmd.exe. I assume popen is
directly spawing pg_dump, but pg_dump does not know the command line
argument >.

you need to run: 'cmd.exe /c pg_dump database > out.txt'

(is it /c or /k, I always get them confused)

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Reg Me Please 2007-10-25 14:24:06 Re: [PGSQL v8.2.5] Similar queries behave differently
Previous Message Andy 2007-10-25 14:20:45 Re: Migration questions for upcoming 8.3 release and fts