32位pyodbc读取64位访问权限(accdb) [英] 32 bit pyodbc reading 64 bit access (accdb)

查看:173
本文介绍了32位pyodbc读取64位访问权限(accdb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 8.1 64位计算机上运行python 2.7 32位.

I have python 2.7 32 bit running on a Windows 8.1 64 bit machine.

我有Access 2013和一个试图从python和pyodbc访问的.accdb文件.

I have Access 2013 and a .accdb file that I'm trying to access from python and pyodbc.

我可以在64位ODBC管理器中创建64位DSN.但是,当我尝试从python连接到它时,出现错误:

I can create a 64 bit DSN in the 64 bit ODBC manager. However, when I try to connect to it from python, I get the error:

错误:(u'IM002',u'[IM002] [Microsoft] [ODBC驱动程序管理器]数据源名称未找到且未指定默认驱动程序')

Error: (u'IM002', u'[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified')

大概是python只是在寻找32位DSN,而没有找到我创建的64位DSN.

Presumably, python is only looking for 32-bit DSNs and doesn't find the 64-bit one that I've created.

当我尝试在32位ODBC管理器中创建32位DSN时,没有用于accdb文件的驱动程序(只是.mdb).

When I try to create a 32-bit DSN within the 32-bit ODBC manager, there is no driver for a accdb file (just .mdb).

我认为我需要一个用于Access 2013文件(.accdb)的32位ODBC驱动程序,但找不到该驱动程序.

I think I need a 32 bit ODBC driver for Access 2013 files (.accdb), but haven't been able to find one.

是否有可能做我想做的事情? -32位python访问Access 2013 .accdb文件吗?

Is it possible to do what I'm trying to do? -- 32bit python access a Access 2013 .accdb file?

推荐答案

包括Python在内的32位应用程序只能与32位ODBC驱动程序一起使用.

32 bit applications including Python can work only with 32 bit ODBC drivers.

包括Python在内的64位应用程序只能与64位ODBC驱动程序一起使用.

64 bit applications including Python can work only with 64 bit ODBC drivers.

如果您有:

  • 具有pyodbc模块的32位Python
  • 64位MS Access ODBC驱动程序
  • 32 bit Python with pyodbc module
  • 64 bit MS Access ODBC driver

然后您必须进行一些更改:

Then you must change something:

  1. 您可以安装64位版本的Python(我使用具有odbc模块的Active Python),然后可以使用64位版本的pyodbc模块(我在Python 2.6、2.7和3.3中看到它)
  2. 您可以安装MS Access驱动程序的32位版本
  1. You can install 64 bit version of Python (I use Active Python which has odbc module), then you can use 64 bit version of pyodbc module (I see it for Python 2.6, 2.7 and 3.3)
  2. You can install 32 bit version od MS Access driver

使用pyodbc.dataSources()您可以列出ODBC源:

Using pyodbc.dataSources() you can list ODBC sources:

sources = pyodbc.dataSources()
dsns = list(sources.keys())
dsns.sort()
sl = []
for dsn in dsns:
    sl.append('%s [%s]' % (dsn, sources[dsn]))
print('\n'.join(sl))

如果您使用ActiveState Python,则可以按照我的食谱使用odbc模块列出它们:

If you use ActiveState Python then you can list them using odbc module as in my recipe: http://code.activestate.com/recipes/578782-printing-list-of-odbc-data-sources/?in=user-186902

这篇关于32位pyodbc读取64位访问权限(accdb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆