pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PyGreSQL pg.error Exception
2+ messages / 2 participants
[nested] [flat]

* PyGreSQL pg.error Exception
@ 2001-07-03 08:33  Denis Gasparin <denis@edinet.it>
  0 siblings, 1 reply; 2+ messages in thread

From: Denis Gasparin @ 2001-07-03 08:33 UTC (permalink / raw)
  To: pgsql-interfaces

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PyGreSQL pg.error Exception
@ 2001-07-03 18:05  Jason Earl <jdearl@yahoo.com>
  parent: Denis Gasparin <denis@edinet.it>
  0 siblings, 0 replies; 2+ messages in thread

From: Jason Earl @ 2001-07-03 18:05 UTC (permalink / raw)
  To: Denis Gasparin <denis@edinet.it>; pgsql-interfaces

Try this:

try:
    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
except.

I hope that is helpful,

Jason

--- Denis Gasparin <denis@edinet.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@postgresql.org
> so that your
> message can get through to the mailing list cleanly


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-07-03 18:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-03 08:33 PyGreSQL pg.error Exception Denis Gasparin <denis@edinet.it>
2001-07-03 18:05 ` Jason Earl <jdearl@yahoo.com>

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