I'm trying to read in a simple access file and read two tables from it. I'm currently just trying to read the file I currently have but I believe I am getting errors due to the M1 chip that the mac has. How should I go about reading this file? I currently have this code which gives me the following error:
I have installed unixodbc although it does not fix the issue.
import pyodbc
import pandas as pd
db_file = r'/Users/michaelschmitz/Work-Programs/Cohort\ Creation/HospitalizationDatabase.accdb'
conn = pyodbc.connect('DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ=' + \
'{};'.format(db_file))
query = "SELECT * FROM mytable "
dataf = pd.read_sql(query, conn)
conn.close()
Current error:
Traceback (most recent call last):
File "/Users/michaelschmitz/Work-Programs/Cohort Creation/CohortCreation.py", line 2, in <module>
import pyodbc
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyodbc.cpython-39-darwin.so, 2): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyodbc.cpython-39-darwin.so
Reason: image not found
I read around and saw that I could connect to docker and use that somehow, but I am fairly inexperienced in that so I'm not quite sure where to begin. Any help would be appreciated, thank you!