Select to view content in your preferred language

PYODBC connection to Access not working within ArcGIS

5929
3
05-08-2020 09:07 AM
MollyMoore
Frequent Contributor

I have a Python script that connects to an Access database, brings in some data, and then appends to a feature layer in ArcGIS.

This script runs okay as a stand-alone script, but I am having issues creating the connection to the Access DB from within ArcGIS Pro. I installed the PYODBC module in the Python manager. Then, when I try to make a connection to the Access DB with the same code that works in the stand-alone script, I get this error message:

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

This happens whether being run in a tool or whether the following code snippet is run from within the Python window in Pro:

conn = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=P:\\Conservation Programs\\Natural Heritage Program\\Data Management\\ACCESS databases\\POND_entry\\POND_be.accdb;')

Any insight would be much appreciated.

0 Kudos
3 Replies
RandyBurton
MVP Alum

Are you connecting to 32 or 64 bit Access?  You might try:

connStr = (
    r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};"
    r"P:\Conservation Programs\Natural Heritage Program\Data Management\ACCESS databases\POND_entry\POND_be.accdb;"
    )
conn = pyodbc.connect(connStr)‍‍‍‍‍
MollyMoore
Frequent Contributor

Ahhh, I'm connecting to Access 32 bit. This is probably the issue, right? 

Is there a workaround for this at all other than the 64 bit install of Access?

0 Kudos
RandyBurton
MVP Alum

You might check out the answer given in this Stackoverflow discussion about the 64 and 32-bit versions of Access 2010.