我希望能够从 R 连接到 MySQL 数据库并在 R 中运行 qry。我找到了一个名为 RMySQL
的包,但它不适用于 R 3.0.3 版。还有其他解决方案吗?
谢谢,
最佳答案
可用。其他选项是 RODBC
Connect R and MySQL
请按照这 3 个命令连接 R 和 MySQL 数据库并执行查询。
require(RMySQL)
con <- dbConnect(MySQL(),user='username',password='password',host='host name/server id',dbname='database_name') #connect R with MySQL database
res <- dbSendQuery(con, "Your SQL query") #Run your SQL query in R
sql_data <- fetch(res, n = -1) #Extract all row(you can set number of rows by changing the value of "n")
关于R 版本 3.0.3 的 MySQL 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23051768/