[python-win32] catching odbc errors in Python/ASP pages

Bill Seitz fluxent at yahoo.com
Mon Apr 23 18:09:33 EDT 2001


Having an implementation problem, ASP pages failing when rolled out to
production server, when they worked fine on dev machine and on staging
server. Trying to track down problem....

I'm re-using code for generic ODBC interaction that some other people gave
me. (Basically just have a single class of database-handling code,
everything else is just in simple Python within the ASP page.) It all works
fine when there's no error. But the error handling never does much. You have
to test for a non-null value on an error message string param, rather than
doing a "try" on a raised exception (the "except:" clause in a given method
sets the param value, then does a "return", not a "raise"). And, there never
seems to a value for that error param. So I can't every catch anything. I
just see the problem at the end result, like when I try to loop over a
resultSet.

In an effort to catch the problem at its source (is it when the connection
gets created? when the cursor gets created?), and get the detailed error
message right there, I tried removing the exception handling completely from
the database class, but then I just end up getting an empty page back from
the server, rather than an error message.

I'm using a current ActiveState Python install, and the generic/base
PythonWin ODBC module. Under Win2K, talking to MsSQL2k.

Are there any tricks, best-practices, etc. for handling exceptions in this
environment? (Or in general: I don't have a lot of experience catching
exceptions, and my books are pre-Python-v2, so don't cover the new
model...).

Other key notes:

- dang code seems to work fine when run interactively from within PythonWin
debugger on server.

- other python-powered ASP pages work fine, so there's not some basic
install-config problem

- when I take all the code out of a separate Python class and put it right
in the ASP page, it returns an empty page instead of an error msg, also.








More information about the Python-list mailing list