From: gerhard q. <gq...@sk...> - 2003-10-21 17:41:34
|
Hi Terry, try this: try: do query except PgSQL.OperationalError, msg: ... Cheers, Gerhard -------------- Terry MacDonald wrote: > Hi,=20 >=20 > 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 tha= t > 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...=20 >=20 > try:=20 > do query=20 > except OperationalError:=20 > ....=20 >=20 > ...I get the following error:=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = > Traceback (most recent call last):=20 >=20 > File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line > 335, in HandlerDispatch=20 > result =3D object(req)=20 >=20 > File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line= > 194, in handler=20 > result =3D apply(object, (), args)=20 >=20 > File "/var/www/html/python/cricket.py", line 60, in registerLeague=20 > except OperationalError:=20 >=20 > NameError: global name 'OperationalError' is not defined=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =20 >=20 > I would have thought the imported module, in this case pgSQL, would hav= e > defined them and made them available to calling modules, but obviously > this is not the case.=20 >=20 > Any help much appreciated and I am sure the solution will educate me > more in how python works and how to use it.=20 >=20 > Cheers,=20 >=20 > Terry=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by OSDN developer relations > Here's your chance to show off your extensive product knowledge > We want to know what you know. Tell us and you have a chance to win $10= 0 > http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 > _______________________________________________ > Pypgsql-users mailing list > Pyp...@li... > https://lists.sourceforge.net/lists/listinfo/pypgsql-users >=20 --=20 ------------------------------------------------------ skequell ------ Gerhard Quell Software & Knowledge Engineering Sch=FCtzenweg 3 eMail: gq...@sk... Fon: 0731-26400651 89275 Elchingen web : http://www.skequell.de Fax: 0731-26400652 ---Aus Sicherheitsgr=FCnden: bitte keine Word-, Excel-Dateianh=E4nge ----= - |