问题
I'm trying to connect to a MS Access Database (.accdb file) via python.
I used pyodbc to do this connection:
import pyodbc
conn = pyodbc.connect("DRIVER = {Microsoft Access Driver (*.mdb, *.accdb)}; DBG=C:\\test_db.accdb")
However, I got the following error:
('IM002, '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
I went to the ODBC Data Source Administrator and when I tried to configure or remove the Driver I got the message:
Errors Found:
The specified DSN contains an architecture mismatch between the Driver and Application
I found that this error is provoked by an incompatibility between versions of Windows (windows 7 - 64bit) and Microsoft Access (Office 2010 - 32bits). I tried to reinstall the driver several times, both with 32 and 64bit versions but the problem wasn't solved. Could you please help me to solve this problem? Thank you in advance.
回答1:
You have to make sure the Python version matches the ODBC driver version: 32-bit with 32-bit, 64-bit with 64-bit.
It looks like you have 64-bit Python / pyodbc and 32-bit MS Access.
What you'll need to do is install the 32-bit Python version, and then install pyodbc
.
Good luck!
来源:https://stackoverflow.com/questions/36965600/pyodbc-the-specified-dsn-contains-an-architecture-mismatch-between-the-driver