[英]RMySQL fetch - can't find inherited method
我想使用RMySQL将数据库中的数据加载到R中的数据框中。为此,我使用以下代码:
Rconnectdb:
con <- dbConnect(MySQL(),
user="root", password="password",
dbname="prediction", host="localhost")
主要代号
library(RMySQL)
source("Rconnectdb") #load the database connection
query = "select received,isRefound from message" #specify query
rs=dbGetQuery(con,query) #resultset
dataset <- fetch(rs, n=-1) #fill dataset with all rows of the resultset
dbClearResult(rs) #clear resultset
执行此我得到以下错误
函数错误(类,fdef,mtable):无法找到函数“ fetch”,签名“ data.frame”,“数字”的继承方法
有任何想法吗?
您将dbSendQuery
与dbGetQuery
。
dbGetQuery
结合dbSendQuery
, fetch
和dbClearResult
按文件:
dbSendQuery
函数仅向数据库引擎提交并同步执行SQL语句。 它不会提取任何记录-为此,您需要使用函数fetch
(确保在完成提取所需的记录时调用dbClearResult
)。函数
dbGetQuery
一次操作dbGetQuery
完成所有这些操作(提交语句,获取所有输出记录,并清除结果集)。
来自软件包DBI
?dbGetQuery
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.