mxODBC and exceptions

Mikael Lexén lexen at telia.com
Wed Sep 12 03:55:09 EDT 2001


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

>>> 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?

--

/Mikael




More information about the Python-list mailing list