Robin: Odbc is still maintained. It is not deprecated, exactly, but is obsolescent since it uses db api version 1 calls. It is maintained that way so that it doesn't break old code. The bug report is appreciated, I'll make sure it gets into the sourceforge bug list if you don't beat me to it.
The up-to-date data access method is adodbapi, which uses the db api version 2 (PEP 249) standard, and is also included in pywin32. ODBC may be a little faster than adodbapi, since It is written in C, while adodbapi is written in pure Python. I doubt whether the difference would be noticeable in most cases. Adodbapi has lots more features, since I keep adding things I admire in other db api packages or want for myself. The latest version (not released in pywin32 yet) even has named-column data retrieval. That has been on my to-do list for years. Since ado defaults to odbc mode, you can simply send an odbc connection string, such as a DSN, to it, and it will do the right thing. In simple programs, conversion is as simple as changing the import statement and the connection method. Your example becomes: <console dump> >>> try: ... import adodbapi as db ... print db.__file__ ... conn = db.connect('not_a_db_path') ... except: ... raise ... c:\python26\lib\site-packages\adodbapi\__init__.py Traceback (most recent call last): File "<stdin>", line 4, in <module> File "c:\python26\lib\site-packages\adodbapi\adodbapi.py", line 307, in connect raise OperationalError(e, "Error opening connection: " + connection_string) adodbapi.adodbapi.OperationalError: (com_error(-2147352567, 'Exception occurred.',(0, u'Microsoft OLE DB Provider for ODBC Drivers', u'[Microsoft][ODBC DriverManager] Data source name not found and no default driver specified', None, 0, -2147467259), None), 'Error opening connection: not_a_db_path') >>> </console dump> On Nov 30, 2010 8:47 AM, "Robin Becker" <ro...@reportlab.com> wrote: I don't know if the odbc module is deprecated, but I'm seeing this strangeness C:\code\rlextra\examples\graphics>cat toad.py try: import odbc print odbc.__file__ conn = odbc.odbc('not_a_db_path') except: raise C:\code\rlextra\examples\graphics>toad.py C:\Python26\lib\site-packages\win32\odbc.pyd Traceback (most recent call last): File "C:\code\rlextra\examples\graphics\toad.py", line 6, in <module> raise TypeError: exceptions must be classes or instances, not str C:\code\rlextra\examples\graphics> so I guess odbc must be raising a string exception -- Robin Becker _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32