简体   繁体   English

使用64位R从32位Access数据库读取数据

[英]Reading data from 32-bit Access db using 64-bit R

System specs: 64-bit OS (Win7), 64-bit R (3.3.3), 32-bit MS Access (2016). 系统规格:64位OS(Win7),64位R(3.3.3),32位MS Access(2016)。

I have data in a 32-bit .accdb file and I want to read it into R. I tried this: 我有32位.accdb文件中的数据,我想将其读入R。

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

but saw the following error: 但看到以下错误:

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

Web search indicated that the bit difference between R and the database is the culprit. 网络搜索表明,R和数据库之间的位差异是罪魁祸首。 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). Windows中的默认ODBC管理器不包含用于MS Access的驱动程序(或者,似乎包含,但尝试使用该工具进行管理会导致体系结构错误)。 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: 遵循其他建议,我将ODBC管理器用于32位程序(c:\\ windows \\ sysWOW64 \\ odbcad32.exe),以使用MS Access文件的新名称创建新的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? 是否存在已知的解决方法?

The access file itself knows nothing about bitness, its only about the client application and the bitness of the odbc driver: 访问文件本身不了解位,仅了解客户端应用程序和odbc驱动程序的位:

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是64位,则需要使用64位ODBC驱动程序进行访问,因此也要使用64位的odbc管理器,它是C:\\Windows\\System32\\odbcad32.exe (在Win7 64位中)。

While if your R is 32bit, you need the 32bit ODBC driver, located at C:\\Windows\\SysWOW64\\odbcad32.exe . 如果R是32位的,则需要32位ODBC驱动程序,该驱动程序位于C:\\Windows\\SysWOW64\\odbcad32.exe

You can download the required Access Database Engine 2010 Redistributable from here: https://www.microsoft.com/en-US/download/details.aspx?id=13255 您可以从此处下载所需的Access Database Engine 2010 Redistributable: https//www.microsoft.com/zh-cn/download/details.aspx? id = 13255

So, download the 64 bit Access Database driver, create a 64bit DSN entry and you should be fine. 因此,下载64位Access Database驱动程序,创建一个64位DSN条目,就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM