pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vadim Pestovnikov <vadim.pestovnikov@gmail.com>
To: pgsql-admin@postgresql.org
Subject: handling errors of os.error module
Date: Fri, 5 May 2006 17:02:52 -0400
Message-ID: <d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com> (raw)

Hi all,

When I create a database dump in python script and if there are some
errors depending on database like user_name is not correct, db_name
doesn't exist or something else I need to handle this error and send
an e-mail notification to my admin. How can I do it?

I tried to use like this, but it doesn't work.

#!/usr/bin/python
import os

try:
    os.system("pg_dump -U user_name -i -F c -v db_name -f file_name.backup")
    print "%s backup has been completed" % ("Database XXX")

except os.error, error:

    # ...
    # here sending e-mail if there is an error of backing up
    # ...

    print "Backup error %s" % error


--
Sincerely,
Vadim Pestovnikov


Message-ID: <d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com>
Permalink:  ../d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com/
Also on:    postgresql.org/message-id/d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: vadim.pestovnikov@gmail.com
  Subject: Re: handling errors of os.error module
  In-Reply-To: <d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com>
  References: <d1556ada0605051402m970a0aaj686b9d4af010eb48@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox