Search code examples
pythonms-access

Error Code When Trying to Connect to Microsoft Access DB in Python


I receive the following error when trying to connect to an MS Access DB in Python:

('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

This was the code block I used:

import pyodbc
conn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=S:\filepath\filename.accdb;')

What could be causing this error?


Solution

  • Cause of the error message: compatibility issues between 64bit Python and 32bit Microsoft Access. After downloading the 64bit version of Microsoft Office, there is no longer an error when creating a connection with a Microsoft Access Database.