SQL-Statement with Python
Alex Martelli
aleaxit at yahoo.com
Thu Jan 18 03:52:46 EST 2001
"Tim Roberts" <timr at probo.com> wrote in message
news:28uc6ts3fn93pon3tahrvbqb26bc4of9hq at 4ax.com...
> "Alex Martelli" <aleaxit at yahoo.com> wrote:
> >
> >import win32com.client
> >
> >connection = win32com.client.Dispatch("AdoDb.Connection")
> >connection.Provider = "Microsoft.Jet.OLEDB.4.0"
> >filename = r'd:\\mssdk\\bin\\nwind.mdb'
>
> Thank you for providing this simple and understandable ADODB example. I
do
> have one nit in that last line. I think you want EITHER the "r" prefix,
OR
> the double backslashes. Including both is just too much of a good
thing...
Oops -- you're perfectly right! Funny thing is that the code as I
posted it *DOES* work -- dunno who's removing the extra backslashes,
or why they don't hurt things.
Note that this is *NOT* a case where forward slashes can be used
instead of backward ones! Changing the filename assignment to:
filename = 'd:/mssdk/bin/wind.mdb'
results in an exception on connection.Open:
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft
JET Da
tabase Engine', "Could not find file 'd:\\mssdk\\bin\\wind.mdb'.", None,
5003024
, -2147467259), None)
yep, the exeption message DOES have backslashes again, and:
D:\Python20>dir d:\mssdk\bin\*.mdb
Volume in drive D has no label.
Volume Serial Number is 0498-B4C2
Directory of d:\mssdk\bin
02/02/00 10:17p 1,558,528 nwind.Mdb
1 File(s) 1,558,528 bytes
146,759,680 bytes free
Using:
filename = 'd:\\mssdk\\bin\\nwind.mdb'
or:
filename = r'd:\mssdk\bin\nwind.mdb'
works fine and seems more sensible.
Alex
More information about the Python-list
mailing list