PyODBC Driver to Connect to Access DB

6857
1
Jump to solution
07-18-2022 08:19 AM
BenRomlein
Occasional Contributor

I'm on Windows with ArcGIS Pro 3.0.0 using the Python environment installed with ArcGIS Pro (arcgispro-py3 from Pro's install directory in Program Files) and I'm trying to make a database connection to an access database like so:

import pyodb
conn_string = r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};' \
r'DBQ=C:path\to\mydatabase.mdb;'
connection = pyodbc.connect(conn_string)

I'm getting this error:

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

When I look at my drivers I see this:

>>>print(pyodbc.drivers())
['SQL Server', 'SQL Server Native Client 11.0', 'ODBC Driver 17 for SQL Server']

How can I make this connection work?

I've tried using a virtual environment (and explicitly uninstalling/reinstalling pyodbc from there) uninstalling/reinstalling ArcGIS Pro, and downgrading ArcGIS Pro to 2.9.

0 Kudos
1 Solution

Accepted Solutions
BenRomlein
Occasional Contributor

in my case, I was able to download and install the missing driver on my machine:

https://www.microsoft.com/en-us/download/details.aspx?id=54920

View solution in original post

1 Reply
BenRomlein
Occasional Contributor

in my case, I was able to download and install the missing driver on my machine:

https://www.microsoft.com/en-us/download/details.aspx?id=54920