Re: running pg_dump from python

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Garry Saddington <garry(at)schoolteachers(dot)co(dot)uk>
Cc: Scott Mead <scott(dot)lists(at)enterprisedb(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: running pg_dump from python
Date: 2009-06-14 22:36:33
Message-ID: 19930.1245018993@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Garry Saddington <garry(at)schoolteachers(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2009-06-14 23:04:37 Re: Opinions on how to Integrate Transactions
Previous Message David Fetter 2009-06-14 22:24:19 Re: [GENERAL] Using results from DELETE ... RETURNING