[egenix-users]
Catching informational messages in mxODBC and discarding them
Martin J. Evans
martin.evans at easysoft.com
Tue Oct 19 19:02:14 CEST 2004
Hi,
I have some python which uses mxODBC to insert into a database. The insert
causes an ODBC SQL_SUCCESS_WITH_INFO return in execute() and outputs the
diagnostic to the terminal. I don't want to see this. I am no Python expert by
a long way. I read "2.7.1 Database Warnings" saying you can catch warnings by
setting an error handler but I don't know how to tie the error handler to my
connection e.g.
import mx.ODBC.unixODBC as mx
db = mx.DriverConnect('DSN=test;UID=user;PWD=password;')
db.errorhandler = None # want to insert the name of my handler here
# as per 2.7.1 example
c = db.cursor()
c.execute('use test')
fails with "TypeError: attribute 'errorhandler' unknown or read-only". I know
the example above is not an insert but the "use test" to MS SQL Server
causes an informational.
I saw mxODBC can be compiled to stop the display of informationals but
that is not an option for me.
I am using mxODBC 2.0.1 if that makes a difference.
Any ideas?
Martin
--
Martin J. Evans
Easysoft Ltd, UK
Development
More information about the egenix-users
mailing list