Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyodbc - The specified DSN contains an architecture mismatch between the Driver and Application

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.

like image 730
jpceia Avatar asked May 01 '16 10:05

jpceia


1 Answers

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!

like image 181
FlipperPA Avatar answered Oct 27 '22 00:10

FlipperPA