3

I am trying to connect pyodbc to an mdb file. I have searched this site and tried a number of things without success. Here is an overview of my system.

Windows 7 Ultimate Service Pack 1
64 Operating System
Python 3.4.0 installed in C:\Python34\ installed using python-3.4.0.amd64.msi
pyodbc 3.0.7 installed using pyodbc-3.0.7.win-amd64-py3.4.exe
Installed AccessDatabaseEngine.exe 14.0.6119.5000 MS 2007 Office System Driver
Control Panel\All Control Panel Items\Administrative Tools Data Sources (ODBC) set to %windir%\SysWOW64\odbcad32.exe
Permissions in the Registry for my user profile set to Full for Microsoft Access Driver (*.mdb, *.accdb)

The code that I am using is:
import csv, pyodbc
conn=pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=c:\MDBTest\MyTestMdb.mdb;')

The error that I continue to get using a number of variations of the code is:
conn=pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=c:\MDBTest\MyTestMdb.mdb;')
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

Thanks in advance for your help.

user3579106
  • 251
  • 1
  • 2
  • 9

1 Answers1

3

You are using a 64-bit version of Python but you have the 32-bit version of the Access Database Engine installed. You either need to

  • run a 32-bit version of Python, or
  • remove the 32-bit version of the Access Database Engine and install the 64-bit version (available here).
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
  • Thank you very much Gord. I didn't think I could run the 64 bit engine with my 32 bit Office, so I uninstalled Python and PYODBC and installed the 32 bit versions of them. The code ran fine. Thanks again!! – user3579106 Jan 15 '15 at 00:09
  • Thanks Gord! Windows 10 x64 control panel showed both 32 and 64 bit odbc drivers installed, but I got the same IM002 error. Installing 32 bit Python, Visual Studio C++ build tools, and then pyodbc fixed the problem. (pyodbc installs fine without compiling in 64 bit Python.) Now I just need to fix my [42000] Programming Error :-). – Dave Apr 02 '21 at 13:07