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

Roger Upole rwupole at msn.com
Tue Jun 3 02:27:55 CEST 2008


Vernon Cole wrote:
> 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

Tim Golden is starting a collection of snippets and examples here:

http://timgolden.me.uk/python-on-windows/

You might want to ask if he could add a section for
database operations.

       Roger




More information about the python-win32 mailing list