ODBC vs ADO (was Re: Where to find the 'dbi' and 'odbc' modules?)

Alex Martelli aleaxit at yahoo.com
Thu Jan 18 05:14:28 EST 2001


"Satheesh Babu" <vsbabu at erols.com> wrote in message
news:945a14$904$1 at bob.news.rcn.net...
> > My favourite way of accessing DB's on NT (fastest, convenient) is
> > via Microsoft's ADO/AODX object model; you can use it (just like you
> > can use any other COM/Automation object model) via module win32com,
>
> Alex,
>
> If you have any very small example on using ADO + Python to connect
> to an ODBC source and execute a query, can you send that to me.

I've posted the very small example (and variations on it) yesterday
on the thread titled "SQL-Statement with Python", but it does *NOT*
'connect to an ODBC source', and I have no experience using ADO to
connect to ODBC sources -- I use it to connect to Jet, SQL Server,
MSDE, Oracle, and other providers yet, but I've never connected it
to the ODBC provider.

The only needed variation SHOULD be how you set Connection string,
typically to something like:
    "Provider=MSDASQL;DSN=dsnName;UID=userName;PWD=userPassword;"
but I only know this from the MS docs -- I've never used it.  I
also know from the docs that the 'Provider=MSDASQL' part can be
omitted (it's the default OleDb provider!), so you _could_ use a
connection string identical to the ODBC connection string you
would use with native ODBC (DSN= or FileDSN= for 'normal' DSN
stuff defined via "ODBC Data Source Administrator"; or, without
a DSN, by explicitly specifying DRIVER, SERVER, DATABASE; but
that's just old ODBC business-as-usual, and I assume somebody
who wants to use ODBC knows this stuff already).


If you DO have to use ODBC, rather than the native OleDb/ADO providers,
then I guess you might as well program to the ODBC level, say with
mxODBC; it's nice to have a way to talk ADO to an ODBC source, as a
'backstop' removing any doubts about the feasibility of using ADO-only
for an application ("yes, you *can* still connect to that old DB over
there in an emergency"), but if ODBC *had* to be my sole connection,
that's what I would use (at least in Python, which gives decent ODBC
functionality; might be different if Visual Basic, data-enabled OCX
controls, etc, had to be used -- but I haven't done that much).


Alex






More information about the Python-list mailing list