RODBC和访问-加载数据 [英] RODBC and Access - Loading data
问题描述
我正在尝试从Access数据库中将一些数据加载到R中.我可以找到所有使用odbcConnectAccess("file.mdb")的指令,但似乎无法加载此功能.它是否已被替换或重命名?还有另一种方法吗?我已经用库("RODBC")加载了RODBC,但是仍然没有运气.
I am trying to load some data into R from an Access database. All of the instructions I can find say to use odbcConnectAccess("file.mdb") but I cannot seem to load this function. Has it been replaced or renamed? Is there another way to do this? I've loaded RODBC with library("RODBC") but still have no luck.
谢谢!
推荐答案
If you're using on a Mac, I've found success using Actual Technologies drivers to connect to Access databases. If you've already set up the ODBC connection, using ODBC Source Administrator on Windows or ODBC Administrator on a Mac, the rest is fairly straightforward.
library(RODBC)
# Open up channel to database supplying name of ODBC connection and user name
data.ch<-odbcConnect("ODBC_Connection_name",uid="user_name")
在odbcConnect中也可以选择提供密码,但是我已经设置了包含密码的连接.
There is also an option to supply a password in odbcConnect, but I've set up the connection with the password included.
sqlTables(data.ch) # Query the connection for all tables
# Fetch all data from a table called "Table_name" or use standard SQL statements
df<-sqlFetch(data.ch,"Table_name")
这篇关于RODBC和访问-加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!