[python-win32] adodbapi SQL access micro how-to (pywin32 build 211)

Vernon Cole vernondcole at gmail.com
Tue Jun 3 00:04:15 CEST 2008


I've just had a success story with the adodbapi now included in build 211,
and thought it would be a good idea to let everyone know how to do it.

My application ran a very gnarly SQL script against master..sysprocesses to
identify blocked SQL requests. It tended to crash python when the MSSQL
server was running badly, which was, of course, when I needed it most.  It
happened again today.

I replaced:
import dbi, odbc
conn = odbc.odbc("Oasis Data/oareport/xxxxx")

with:
import adodbapi
conn = adodbapi.connect("DSN=Oasis Data; Uid=oareport; Pwd=xxxxx")

and presto! the script runs with no errors and no other changes.
<http://www.connectionstrings.com>
A working example of creating and connecting to a Microsoft Access type
(a.k.a. "jet") database can be found in
Lib/site-packages/adodbapi/tests/adodbapitestconfig.py. There are also
MSSQL, mysql, and AS400 examples in that file.

Connection string examples for many other situations can be found at
www.connectionstrings.com
--
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080602/d829509a/attachment.htm>


More information about the python-win32 mailing list