collarblind
collarblind

Reputation: 4739

Python pyodbc connect to ms access database

I am trying to connect my access database so I can dump my data into the table in the database. This the code I use:

import pyodbc
access_database_file = "C:\\Users\\Moyp\\DataPointe.accdb"
ODBC_CONN_STR = 'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s;' %access_database_file
conn = pyodbc.connect(ODBC_CONN_STR)

However, I keep receiving this error:

Traceback (most recent call last):
  File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-6-a4daec7c49a9>", line 1, in <module>
    conn = pyodbc.connect(ODBC_CONN_STR)
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

Upvotes: 2

Views: 2814

Answers (1)

collarblind
collarblind

Reputation: 4739

I fixed the issue. I was using 64 bit Python and 32 bit MS Access. After I downgraded my 64 bit Python to 32 it worked fine.

Upvotes: 6

Related Questions