| 
      
      
      From: Terry M. <te...@i3...> - 2003-10-21 13:20:02
      
     | 
| Hi, 
I am fairly new to using python and pypgsql and what I may ask here may
be solved by the obvious, so my apologies if this sounds dumb, but I
have looked around all the (sparse) documentation and found nothing that
helps. Anyway how do I get my program, that imports pgSQL, to recognise
the DB API exception values, e.g. OperationalError, for when I place
them in a try...except block ala... 
    try: 
        do query 
    except OperationalError: 
       .... 
...I get the following error: 
========================================================================= 
Traceback (most recent call last): 
  File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line
335, in HandlerDispatch 
    result = object(req) 
  File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line
194, in handler 
    result = apply(object, (), args) 
  File "/var/www/html/python/cricket.py", line 60, in registerLeague 
    except OperationalError: 
NameError: global name 'OperationalError' is not defined 
========================================================================== 
I would have thought the imported module, in this case pgSQL, would have
defined them and made them available to calling modules, but obviously
this is not the case. 
Any help much appreciated and I am sure the solution will educate me
more in how python works and how to use it. 
Cheers, 
Terry 
 |