pyodbc连接到mdb文件 [英] pyodbc connection to mdb file
问题描述
我正在尝试将pyodbc连接到mdb文件.我已经搜索了该站点,并尝试了许多尝试,但均未成功.这是我的系统的概述.
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操作系统
使用python-3.4.0.amd64.msi安装在C:\ Python34 \中的Python 3.4.0
使用pyodbc-3.0.7.win-amd64-py3.4.exe安装的pyodbc 3.0.7
已安装AccessDatabaseEngine.exe 14.0.6119.5000 MS 2007 Office System驱动程序
控制面板\所有控制面板项目\管理工具数据源(ODBC)设置为%windir%\ SysWOW64 \ odbcad32.exe
对于我的用户配置文件,注册表中的权限对于Microsoft Access Driver(* .mdb,*.accdb)设置为完全"
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)
我正在使用的代码是:
导入csv,pyodbc
conn = pyodbc.connect('Driver = {Microsoft Access驱动程序(* .mdb,* .accdb)}; Dbq = c:\ MDBTest \ MyTestMdb.mdb;')
The code that I am using is:
import csv, pyodbc
conn=pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=c:\MDBTest\MyTestMdb.mdb;')
我继续使用代码的多种变体得出的错误是:
conn = pyodbc.connect('Driver = {Microsoft Access驱动程序(* .mdb,* .accdb)}; Dbq = c:\ MDBTest \ MyTestMdb.mdb;')
pyodbc.Error :("IM002","[IM002] [Microsoft] [ODBC驱动程序管理器]数据源名称未找到且未指定默认驱动程序(0)(SQLDriverConnect)")
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)')
预先感谢您的帮助.
推荐答案
您正在使用64位版本的Python,但已安装32位版本的Access数据库引擎.您要么需要
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
- 运行32位版本的Python,或
- 删除32位版本的Access数据库引擎并安装64位版本(可使用 查看全文