I am on Win7 x64, using Python 2.7.1 x64. I am porting an application I created in VC++ to Python for educational purpouses.
The original application has no problem connecting to the MS Access 2007 format DB file by using the following connection string:
OleDbConnection^ conn = gcnew OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=|DataDirectory|DB.accdb");
Now, when I try to connect to the same DB file (put in C: this time) in Python using pyodbc and the following conenction string:
conn = pyodbc.connect("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:DB.accdb;")
, and no matter whether I keep the OLEDB provider or I use the Provider=MSDASQL;
as mentioned here (MS mentions it's not availiable for 64bit), I keep getting the following error:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')
What might cause this problem?
ADD:
I have looked into pyodbc docs more closely and tried conn = pyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=c:\DB.accdb;")
- the same error. This is really weird, since the pyodbc.dataSources() shows that I have this provider.
ADD2:
I tried win32com.client usage such as here in order to connect by using OLE DB - no success. Seems that it's impossible, nothing works.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…