Re: running pg_dump from python

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: running pg_dump from python
Дата
Msg-id 19930.1245018993@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: running pg_dump from python  (Garry Saddington <garry@schoolteachers.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: Garry Saddington
Дата:
Сообщение: Re: running pg_dump from python
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: Opinions on how to Integrate Transactions