mxODBC error trapping
Daley, MarkX
markx.daley at intel.com
Tue Apr 25 13:45:38 EDT 2000
I am accessing databases using the notes by John Dell'Aquila for ODBC using
Python Database API. It works fine, but now I am trying to set up error
trapping in the event that a connection fails to be made. Here is the basic
code structure:
def collect():
"Routine to query all servers for all names for time period defined
in timer."
# Define some variables
for index in servername:
try:
# Big routine to collect data and write to file
except dbi.operation-error:
servername.append(index)
Here is the error message I get:
Traceback (innermost last):
File "<pyshell#2>", line 1, in ?
collect.collect()
File "C:\PROGRA~1\Python\collect.py", line 50, in collect
except dbi.operation-error:
AttributeError: operation
If I change the exception to just OperationError, I get this:
Traceback (innermost last):
File "<pyshell#1>", line 1, in ?
collect.collect()
File "C:\PROGRA~1\Python\collect.py", line 50, in collect
except OperationalError:
NameError: OperationalError
I guess I don't know enough about exceptions to trap them properly. Any
hints?
- Mark
More information about the Python-list
mailing list