-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated getSymbols.MySQL SELECT statement to include dbname variable … #88
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -599,7 +599,7 @@ function(Symbols,env,return.class='xts', | |
db.fields=c('date','o','h','l','c','v','a'), | ||
field.names = NULL, | ||
user=NULL,password=NULL,dbname=NULL,host='localhost',port=3306, | ||
...) { | ||
from=NULL, to=NULL, ...) { | ||
importDefaults("getSymbols.MySQL") | ||
this.env <- environment() | ||
for(var in names(list(...))) { | ||
|
@@ -631,7 +631,13 @@ function(Symbols,env,return.class='xts', | |
if(verbose) { | ||
cat(paste('Loading ',Symbols[[i]],paste(rep('.',10-nchar(Symbols[[i]])),collapse=''),sep='')) | ||
} | ||
query <- paste("SELECT ",paste(db.fields,collapse=',')," FROM ",Symbols[[i]]," ORDER BY date") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding the backticks would have been cleaner as: query <- paste("SELECT ",paste(db.fields,collapse=',')," FROM `",Symbols[[i]],"` ORDER BY date",sep="") It would also be good to separate this change from the change that adds the |
||
if (!is.null(from) & !is.null(to)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implies that the user must specify both |
||
query <- paste("SELECT ", paste(db.fields, collapse = ","), " FROM ", paste("`", Symbols[[i]], "`", sep = ""), " WHERE date >= '", from, "' AND date <= '", to, "' ORDER BY date") | ||
} else { | ||
query <- paste("SELECT ", paste(db.fields, collapse = ","), " FROM ", paste("`", Symbols[[i]], "`", sep = ""), " ORDER BY date") | ||
} | ||
|
||
rs <- DBI::dbSendQuery(con, query) | ||
fr <- DBI::fetch(rs, n=-1) | ||
#fr <- data.frame(fr[,-1],row.names=fr[,1]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new arguments need to be documented in the corresponding .Rd file. You can use
man/getSymbols.yahoo.Rd
as a template. Though I'm not sure the defaults forgetSymbols.yahoo
make sense here.