使用64位R从32位Access数据库读取数据 [英] Reading data from 32-bit Access db using 64-bit R

查看:341
本文介绍了使用64位R从32位Access数据库读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系统规格:64位OS(Win7),64位R(3.3.3),32位MS Access(2016).

System specs: 64-bit OS (Win7), 64-bit R (3.3.3), 32-bit MS Access (2016).

我有一个32位.accdb文件中的数据,我想将其读入R.我尝试了此操作:

I have data in a 32-bit .accdb file and I want to read it into R. I tried this:

con <- odbc::dbConnect(odbc::odbc(),
                       dsn="MS Access Database")

但看到以下错误:

Error: nanodbc/nanodbc.cpp:950: IM014: [Microsoft][ODBC Driver Manager] 
The specified DSN contains an architecture mismatch between the Driver and Application 

网络搜索表明R与数据库之间的位差是罪魁祸首. Windows中的默认ODBC管理器不包含用于MS Access的驱动程序(或者,似乎,但尝试使用该工具进行管理会给您带来体系结构错误).遵循其他建议,我使用ODBC管理器处理32位程序(c:\ windows \ sysWOW64 \ odbcad32.exe),以使用MS Access文件的新名称创建新的DSN,然后将此DSN命名为:

Web search indicated that the bit difference between R and the database is the culprit. The default ODBC manager in Windows doesn't include drivers for MS Access (or rather, it seems to, but attempting to manage them using that tool gives you an architecture error). Following other advice, I used the ODBC manager for 32-bit programs (c:\windows\sysWOW64\odbcad32.exe) to create a new DSN with a new name for MS Access files, and then called this DSN:

con <- odbc::dbConnect(odbc::odbc(),
                       dsn="MSAccess32")

但是,我遇到了同样的错误,并且怀疑这个错误意味着什么我不了解.有已知的解决方法吗?

I got the same error, however, and suspect there is something I don't understand about what this error means. Is there a known workaround for the problem?

推荐答案

访问文件本身不了解位数,仅了解客户端应用程序和odbc驱动程序的位数:

The access file itself knows nothing about bitness, its only about the client application and the bitness of the odbc driver:

如果R是64位,则需要使用64位ODBC驱动程序进行访问,因此也请使用64位的odbc管理器,该管理器为C:\Windows\System32\odbcad32.exe(在Win7 64位中).

If your R is 64 bit, you need the 64bit ODBC driver for access and therefore also use the odbc manager for 64bit, which is C:\Windows\System32\odbcad32.exe (in Win7 64bit).

如果您的R是32位,则需要位于C:\Windows\SysWOW64\odbcad32.exe的32位ODBC驱动程序.

While if your R is 32bit, you need the 32bit ODBC driver, located at C:\Windows\SysWOW64\odbcad32.exe.

您可以从此处下载所需的Access Database Engine 2010 Redistributable:

You can download the required Access Database Engine 2010 Redistributable from here: https://www.microsoft.com/en-US/download/details.aspx?id=13255

因此,下载64位Access Database驱动程序,创建一个64位DSN条目,您应该会很好.

So, download the 64 bit Access Database driver, create a 64bit DSN entry and you should be fine.

这篇关于使用64位R从32位Access数据库读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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