[R-SIG-Finance] quantmod getSymbols executes MySQL queries without escaping symbol/ticker data
Sergey Pisarenko
drseergio at gmail.com
Wed Jan 25 06:38:54 CET 2012
Hi,
I have opened the source of getSymbols.R and indeed there is no
escaping going on. I will modify the source and add escaping. I will
then test and submit a patch.
/Sergey
On Tue, Jan 24, 2012 at 11:02 PM, Sergey Pisarenko <drseergio at gmail.com> wrote:
> 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