pyodbc connection to mdb file

戏子无情 提交于 2019-12-08 01:36:36

问题


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.


回答1:


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).


来源:https://stackoverflow.com/questions/27952893/pyodbc-connection-to-mdb-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!