将来自Microsoft SQL Server的数据读入R

时间:2021-04-24 10:35:13

Is it possible to read the data stored in MS SQL server from R interface?

是否可以从R接口读取存储在MS SQL server中的数据?

If it is I would be also thankful if anyone could show the way to do it.

如果是的话,我也会很感激,如果有人能告诉我怎么做。

5 个解决方案

#1


18  

Tried the RODBC package already?

已经尝试过RODBC包了吗?

http://cran.r-project.org/web/packages/RODBC/index.html

http://cran.r-project.org/web/packages/RODBC/index.html

There's also the RJDBC package : http://www.rforge.net/RJDBC/

还有rforge.net/rjdbc/的RJDBC包

See also : http://www.r-bloggers.com/connecting-to-sql-server-from-r-using-rjdbc/

参见:http://www.r-bloggers.com/connecting-to-sql-server-from-r-using-rjdbc/

#2


6  

Niko, What operating system are you running? The answer to your question varies, depending on the platform you are using.

妮可,你在运行什么操作系统?您的问题的答案是不同的,这取决于您使用的平台。

If you are using Windows (of any stripe), connecting to MSSQL Server via ODBC (RODBC) makes the most sense. When I connect to a MSSQL Server on Linux, I use JDBC as suggested by Joris. I would assume that JDBC is also the best solution for Macs, but I could very well be wrong.

如果您正在使用Windows(任何类型的),那么通过ODBC (RODBC)连接到MSSQL服务器是最有意义的。当我连接到Linux上的MSSQL服务器时,我使用了Joris建议的JDBC。我认为JDBC也是mac最好的解决方案,但我很可能错了。

#3


5  

I've applied RODBC function suggested by other users. LinkSQL Server RODBC Connection

我已经应用了其他用户推荐的RODBC函数。LinkSQL服务器RODBC连接

library(RODBC)
dbhandle <- odbcDriverConnect('driver={SQL 
Server};server=mysqlhost;database=mydbname;trusted_connection=true')
res <- sqlQuery(dbhandle, 'select * from information_schema.tables')

change two variables beased on your Data table. 'server=mysqlhost;database=mydbname'

更改数据表上的两个变量。“服务器= mysqlhost;数据库= mydbname”

#4


5  

There another option that seems to outperform RODBC and RJDBC

还有一种选择似乎比RODBC和RJDBC更胜一筹

rsqlserver package written by agstudy.

由agstudy编写的rsqlserver包。

Installation:

安装:

require(devtools)
install_github("rClr", 'jmp75')
install_github('rsqlserver', 'agstudy',args='--no-multiarch')

#5


2  

The latest library that allows you to connect to MSSQL databases is RSQLServer.

允许您连接到MSSQL数据库的最新库是RSQLServer。

It can be found on GitHub and CRAN.

可以在GitHub和CRAN上找到。

#1


18  

Tried the RODBC package already?

已经尝试过RODBC包了吗?

http://cran.r-project.org/web/packages/RODBC/index.html

http://cran.r-project.org/web/packages/RODBC/index.html

There's also the RJDBC package : http://www.rforge.net/RJDBC/

还有rforge.net/rjdbc/的RJDBC包

See also : http://www.r-bloggers.com/connecting-to-sql-server-from-r-using-rjdbc/

参见:http://www.r-bloggers.com/connecting-to-sql-server-from-r-using-rjdbc/

#2


6  

Niko, What operating system are you running? The answer to your question varies, depending on the platform you are using.

妮可,你在运行什么操作系统?您的问题的答案是不同的,这取决于您使用的平台。

If you are using Windows (of any stripe), connecting to MSSQL Server via ODBC (RODBC) makes the most sense. When I connect to a MSSQL Server on Linux, I use JDBC as suggested by Joris. I would assume that JDBC is also the best solution for Macs, but I could very well be wrong.

如果您正在使用Windows(任何类型的),那么通过ODBC (RODBC)连接到MSSQL服务器是最有意义的。当我连接到Linux上的MSSQL服务器时,我使用了Joris建议的JDBC。我认为JDBC也是mac最好的解决方案,但我很可能错了。

#3


5  

I've applied RODBC function suggested by other users. LinkSQL Server RODBC Connection

我已经应用了其他用户推荐的RODBC函数。LinkSQL服务器RODBC连接

library(RODBC)
dbhandle <- odbcDriverConnect('driver={SQL 
Server};server=mysqlhost;database=mydbname;trusted_connection=true')
res <- sqlQuery(dbhandle, 'select * from information_schema.tables')

change two variables beased on your Data table. 'server=mysqlhost;database=mydbname'

更改数据表上的两个变量。“服务器= mysqlhost;数据库= mydbname”

#4


5  

There another option that seems to outperform RODBC and RJDBC

还有一种选择似乎比RODBC和RJDBC更胜一筹

rsqlserver package written by agstudy.

由agstudy编写的rsqlserver包。

Installation:

安装:

require(devtools)
install_github("rClr", 'jmp75')
install_github('rsqlserver', 'agstudy',args='--no-multiarch')

#5


2  

The latest library that allows you to connect to MSSQL databases is RSQLServer.

允许您连接到MSSQL数据库的最新库是RSQLServer。

It can be found on GitHub and CRAN.

可以在GitHub和CRAN上找到。