Quantmod:从 MySQL 数据库加载符号时出错 [英] Quantmod: Error loading symbols from MySQL DB

查看:26
本文介绍了Quantmod:从 MySQL 数据库加载符号时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 getSymbols 从 MySQL 数据库中获取符号,但是以下代码

I am trying to fetch symbols from a MySQL db using getSymbols, however the following code

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"’

我很确定数据库设置正确,因为以下代码运行良好并按预期返回数据集.

I am pretty sure the db is set up correctly as the following code runs fine and returns the dataset as expected.

 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)

非常感谢任何帮助!

推荐答案

dbConnect"character" 方法 在 R01.01.0 版本中删除了.我不确定这是否是故意的.发行说明中没有提到它.

The "character" method for dbConnect was removed in the 0.10 release of RMySQL. I'm not sure whether or not this was intentional. It was not mentioned in the release notes.

这篇关于Quantmod:从 MySQL 数据库加载符号时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆