mxODBC and exceptions

David Fuess fuess1 at home.com
Wed Sep 12 08:27:18 EDT 2001


On Wed, 12 Sep 2001 09:55:09 +0200, Mikael Lexén <lexen at telia.com>
wrote:

>Hi
>
>I'm using the mxODBC module and I have problem getting the exception
>clause to work.
>I do the following:
>
>import mx.ODBC
>
><code>
>
>try:
>  c.executedirect(Sql)
>
>#except mxODBC.IntegrityError:
>#except IntegrityError:
>except:
>   print "Unexpected error:", sys.exc_info()[0]
>   raise

I use

except Exception, detail:
	<print traceback and detail here>

as a catchall exception catcher

>
>>>> Unexpected error: mxODBC.IntegrityError
>Traceback (most recent call last):
>  File "C:\Program
>Files\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301, in
>RunScript
>    exec codeObject in __main__.__dict__
>  File "C:\python\lisa\domain\add.py", line 61, in ?
>    c.executedirect(Sql)
>IntegrityError: ('23000', 1, '[Oracle][ODBC][Ora]ORA-00001: unique
>constraint (V0ME292.TORR_PK) violated\n', 4523)
>
>
>
>I have tried different exception clause as you can see but it doesn't
>work. What am I doing wrong?




More information about the Python-list mailing list