I am on Win7 x64, using Python 2.7.1 x64. I am porting an application I created in VC++ to Python for educational purpouses.
The original application has no problem connecting to the MS Access 2007 format DB file by using the following connection string:OleDbConnection^ conn = gcnew OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=|DataDirectory|DB.accdb");
Now, when I try to connect to the same DB file (put in C:\ this time) in Python using pyodbc and the following conenction string:conn = pyodbc.connect("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\DB.accdb;")
, and no matter whether I keep the OLEDB provider or I use the Provider=MSDASQL;
as mentioned here (MS mentions it's not availiable for 64bit), I keep getting the following error:
我使用的是Win7 x64,使用的是Python 2.7.1 x64。我正在移植一个我在vc++中创建的应用程序,用于教育purp。原始应用程序没有问题连接到女士访问2007格式DB文件通过以下连接字符串:OleDbConnection康涅狄格州^ = gcnew OleDbConnection(“供应商= Microsoft.ACE.OLEDB.12.0;数据源= | DataDirectory | DB.accdb”);现在,当我尝试使用pyodbc和下面的conenction字符串:conn = pyodbc连接到Python中的同一个DB文件(请输入C:\这次)时。连接(“司机= { Microsoft Access司机(*。mdb,* .accdb)};提供者= Microsoft.ACE.OLEDB.12.0;Data Source=C:\DB.accdb;"),无论我是否保留OLEDB提供程序或我使用提供程序=MSDASQL;正如这里提到的(MS提到64位不承担责任),我一直得到以下错误:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnectW)')
pyodbc。错误:('IM002', '[IM002] [Microsoft][ODBC Driver Manager]数据源名称未找到,未指定默认驱动程序(0)(SQLDriverConnectW)')
What might cause this problem?
什么可能导致这个问题?
ADD: I have looked into pyodbc docs more closely and tried conn = pyodbc.connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=c:\\DB.accdb;")
- the same error. This is really weird, since the pyodbc.dataSources() shows that I have this provider.
添加:我更仔细地研究了pyodbc文档,并尝试了conn = pyodbc。连接(“司机= { Microsoft Access司机(*。mdb,* .accdb)};DBQ = c:\ \ DB.accdb;”)——同样的错误。这非常奇怪,因为pyodbc.dataSources()显示我有这个提供程序。
ADD2: I tried win32com.client usage such as here in order to connect by using OLE DB - no success. Seems that it's impossible, nothing works.
ADD2:我试着win32com。客户端使用,如这里为了连接使用OLE DB -没有成功。似乎这是不可能的,没有什么是有效的。
1 个解决方案
#1
13
-
Try to use something like the following instead of using the same string as the one for OLeDb:
"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\DB.accdb;"
尝试使用如下的方法,而不是使用与OLeDb相同的字符串:“Driver={Microsoft Access Driver(*)。mdb,* .accdb)};DBQ = C:\ DB.accdb;“
-
You may not be able to talk to the driver directly from your x64 Python application: Access 2007 and its ACE driver are 32 bits only.
Instead, get the ACE x64 driver for Access 2010, but be careful that if you already have Access or the ACE driver 32bit installed, it won't work.
I would stick to the 32bit versions of Python and of the ACE driver if you expect your app to be run on other systems: it is not recommended to mix x64 and x86 versions of Office tools and drivers, you'll probably end up with lots of issues if you do.您可能无法直接从x64 Python应用程序与驱动程序对话:Access 2007及其ACE驱动程序只有32位。相反,为Access 2010获取ACE x64驱动程序,但是要注意,如果您已经安装了Access或ACE驱动程序32位,那么它将无法工作。我将坚持ACE的32位版本的Python和司机如果你希望你的应用程序运行在其他系统上:不建议混合x64和x86版本的办公工具和驱动程序,你可能会得到很多问题如果你。
-
If the issue is not with the 32/64bit mix, then maybe this question has the answer you seek.
如果问题不在于32/64位的组合,那么这个问题可能有你想要的答案。
#1
13
-
Try to use something like the following instead of using the same string as the one for OLeDb:
"Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\DB.accdb;"
尝试使用如下的方法,而不是使用与OLeDb相同的字符串:“Driver={Microsoft Access Driver(*)。mdb,* .accdb)};DBQ = C:\ DB.accdb;“
-
You may not be able to talk to the driver directly from your x64 Python application: Access 2007 and its ACE driver are 32 bits only.
Instead, get the ACE x64 driver for Access 2010, but be careful that if you already have Access or the ACE driver 32bit installed, it won't work.
I would stick to the 32bit versions of Python and of the ACE driver if you expect your app to be run on other systems: it is not recommended to mix x64 and x86 versions of Office tools and drivers, you'll probably end up with lots of issues if you do.您可能无法直接从x64 Python应用程序与驱动程序对话:Access 2007及其ACE驱动程序只有32位。相反,为Access 2010获取ACE x64驱动程序,但是要注意,如果您已经安装了Access或ACE驱动程序32位,那么它将无法工作。我将坚持ACE的32位版本的Python和司机如果你希望你的应用程序运行在其他系统上:不建议混合x64和x86版本的办公工具和驱动程序,你可能会得到很多问题如果你。
-
If the issue is not with the 32/64bit mix, then maybe this question has the answer you seek.
如果问题不在于32/64位的组合,那么这个问题可能有你想要的答案。