Skip to content
Prev 13207 / 15274 Next

Problem using Quantmod and MySQL

On Mon, Mar 30, 2015 at 9:25 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote:
I'm happy to try it out but a little confused as to all the locations
I need to edit. Help me clear this up and I'll try it out immediately.

The failure is coming when I'm trying to get the data using the following code:
+   if (!UseMySQL){
+     for (i in 1:length(TestSym)){
+       print(paste("From ",SymbolSrc," -- ",TestSym[i]))
+       getSymbolsCont(TestSym[i], from = DataStart, to = DataEnd,
adjust = MyAdjust, src=SymbolSrc)
+     }
+   } else {
+     for (i in 1:length(TestSym)){
+       print(paste("From MySQL -- ",TestSym[i]))
+ #      getSymbols(TestSym[i], src="MySQL")
+       getSymbols(TestSym[i], src="MySQL", user="mark",
password="MyTempPassword", dbname=dbName)
+       assign(TestSym[i], get(TestSym[i])[paste0(DataStart,"/",DataEnd)])
+     }
+     dbDisconnect(dbc)
+   }
+ }
[1] "From MySQL --  SPY"
 Show Traceback

 Rerun with Debug

Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ?dbConnect? for
signature ?"character"?


Am I correct that the suggestion is to edit two lines?

First, I use

library(RMySQL)

Is the first edit to change this to

requireNamespace("RMySQL", quietly = TRUE)

or do I add this to my code somewhere and keep the library command?

Later in my code I have:

if (UseMySQL){
  if (MyAdjust) { dbName = paste0(dbName, "Adjust")}
  dbc = dbConnect(MySQL(), dbname=dbName)
#  setDefaults(getSymbols.MySQL, user="mark",
password="MyTempPassword", dbname=dbName)
}

This would be where the second edit goes?

dbConnect("MySQL", ...) to dbConnect(RMySQL::MySQL, ...)

Thanks,
Mark