Re: running pg_dump from python - Mailing list pgsql-general

From Tom Lane
Subject Re: running pg_dump from python
Date
Msg-id 19930.1245018993@sss.pgh.pa.us
Whole thread Raw
In response to Re: running pg_dump from python  (Garry Saddington <garry@schoolteachers.co.uk>)
List pgsql-general
Garry Saddington <garry@schoolteachers.co.uk> writes:
>> import  os
>> os.popen("c:/scholarpack/postgres/bin/pg_dump scholarpack  >
>> c:/scholarpack/ancillary/scholarpack.sql")

> scholarpack but no OS user scholarpack, but why should it create a file
> then not fill the contents?

Because that's exactly what will happen if pg_dump fails.  The shell
creates the empty output file and then tries to run the program.
If program fails before sending anything to the output file, that's
what you're left with.

The real problem with this script is it's not even considering the
possibility of program failure --- it's not checking for an error exit
code, much less ensuring that error messages go someplace where you
could look at them to find out what the problem is.

            regards, tom lane

pgsql-general by date:

Previous
From: Garry Saddington
Date:
Subject: Re: running pg_dump from python
Next
From: Tomas Vondra
Date:
Subject: Re: Opinions on how to Integrate Transactions