strange transliteration in win32com.client

Mark Morss mfmorss at aep.com
Tue Oct 23 16:38:37 EDT 2007


Is this the place to ask a win32com.client question?  I am a unix
person trying to run on windows, so I have little familiarity with
this module.  I have this code:

import win32com.client

"""An Access connection"""

def connect(data_source, user, pwd, mdw):
    connAccess = win32com.client.Dispatch(r'ADODB.Connection')
    SOURCE=%s;USER ID=%s;PASSWORD=%s;Jet OLEDB:System Database=%s;"
% (data_source, user, pwd, mdw)
    connAccess.Open(DSN)
    return connAccess

I when I call this, running my program from the windows command line
on the C:\ drive, with data_source='\\Hqwhslfs001\office\risk oversight
\myaccessdb.mdb', which is the fully specified drive name, it comes
back with:

  File "C:\Python25\lib\site-packages\win32com\client\dynamic.py",
line 258, in _ApplyTypes_
    result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
'Microsoft JET Database Engine', "'c:\\Hqwhslfs001\\office\risk
oversight\\myaccess.mdb' is not a valid path.  Make sure that the path
name is spelled correctly and that you are connected to the server on
which the file resides.", None, 5003044, -2147467259), None)

Please note the strange insertion of double slashes in the indicated
'not valid path.'  Also the insertion of 'c:' and the strange leading
double quotation mark.

When I call it with data_source = 'V:\risk oversight\myassessdb.mdb',
which reflects how this same drive is mapped on my machine, I get:

File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
258, in _ApplyTypes_
    result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
'Microsoft JET Database Engine', "'v:\\\risk oversight\
\myaccessdb.mdb' is not a valid path.  Make sure that the path name is
spelled correctly and that you are connected to the server on which
the file resides.", None, 5003044, -2147467259), None)

Note the weird transliteration of data_source.  I am powerless to
understand this.




More information about the Python-list mailing list