[R-SIG-Finance] quantmod getSymbols executes MySQL queries without escaping symbol/ticker data
Sergey Pisarenko
drseergio at gmail.com
Tue Jan 24 23:02:38 CET 2012
Hi fellow R programmers,
I am using quantmod to retrieve historic price data for a range of
stocks. The issue is that the program fails at certain points because
apparently the values that are sent to MySQL are not escaped properly
when quantmod executes sql queries. For example, following stocks will
cause issues: "ABV.C" (because of dot MySQL will think we are trying
to access table C), "ALL" (MySQL thinks this is a reserved sequence).
Here's the code I have:
# code omitted
..
tickers <- dbListTables(con) # con is connection to MySQL db where
tables with stock data exist
for (ticker in tickers) {
bars <- getSymbols(ticker, src="MySQL", auto.assign=FALSE) # it
fails here when data contains special characters
}
Is this expected behavior and is there something I can do about it?
I have tried using "try" and "tryCatch" but the execution breaks anyway.
/Sergey
More information about the R-SIG-Finance
mailing list