Skip site navigation (1) Skip section navigation (2)

Re: PyGreSQL pg.error Exception

From: Jason Earl <jdearl(at)yahoo(dot)com>
To: Denis Gasparin <denis(at)edinet(dot)it>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: PyGreSQL pg.error Exception
Date: 2001-07-03 18:05:35
Message-ID: (view raw or whole thread)
Lists: pgsql-interfaces
Try this:

    db = pg.connect(parameters)
except pg.error, error_message
    print error_message

I tend to write the except statement a little
differently to remind me that the first parameter to
except is actually expecting a tuple.  So instead I
generally write:

except (pg.error,), error_message

Yes, that looks ugly.  But two months later I don't
have to look in the info file to see how to call

I hope that is helpful,


--- Denis Gasparin <denis(at)edinet(dot)it> wrote:
> Hi to all!
>          In the documentation of the PyGreSQL module
> it is said that a 
> pg.error exception is thrown when pg.connect or
> other pg functions cause an 
> error. How can i get the value of the error? I have
> tried print pg.error in 
> the except clause but i get only a _pg.error
> value...
> For example:
> try:
>          db = pg.connect( connection parameters);
> except pg.error:
>          print pg.error;
> This prints "_pg.error"...
> Thanks in advance for your replies,
> Denis
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org
> so that your
> message can get through to the mailing list cleanly

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail

In response to

pgsql-interfaces by date

Next:From: Michael DavisDate: 2001-07-03 22:26:41
Subject: RE: Question
Previous:From: Manika DeyDate: 2001-07-03 16:07:35
Subject: Re: distinguishing different database connections

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group