我正在尝试使用getSymbols从MySQL数据库中获取符号,但是以下代码
library(blotter)
library(DBI)
library(RMySQL)
setDefaults(getSymbols.MySQL,user="****", password="****", dbname="quantmoddb")
currency("USD")
stock("myspy",currency="USD",multiplier=1)
getSymbols("myspy",src="MySQL")
引发
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘dbConnect’ for signature ‘"character"’
我非常确定db已正确设置,因为以下代码运行正常,并按预期返回数据集。
con <- dbConnect(RMySQL::MySQL(),user="****",password="****", dbname="quantmoddb",
host="localhost", port=3306)
db.Symbols <- DBI::dbListTables(con)
query <- paste("SELECT * from myspy ORDER BY date")
rs <- DBI::dbSendQuery(con, query)
fr <- DBI::fetch(rs, n=-1)
非常感谢任何帮助!