Retrieve Data from MySQL Database
Fetch data from MySQL database. As with other
methods extending the getSymbols
function,
this should NOT be called directly. Its
documentation is meant to highlight the formal
arguments, as well as provide a reference for
further user contributed data tools.
getSymbols.MySQL(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, ...)
Symbols |
a character vector specifying the names of each symbol to be loaded |
env |
where to create objects. (.GlobalEnv) |
return.class |
desired class of returned object. Can be xts, zoo, data.frame, or ts. (zoo) |
db.fields |
character vector indicating names of fields to retrieve |
field.names |
names to assign to returned columns |
user |
username to access database |
password |
password to access database |
dbname |
database name |
host |
database host |
port |
database port |
... |
currently not used |
Meant to be called internally by getSymbols
(see also)
One of a few currently defined methods for loading data for
use with quantmod. Its use requires the packages
DBI and MySQL, along with a running
MySQL database with tables corresponding to the
Symbol
name.
The purpose of this abstraction is to make transparent the ‘source’ of the data, allowing instead the user to concentrate on the data itself.
A call to getSymbols.MySQL will load into the specified
environment one object for each Symbol
specified,
with class defined by return.class
.
The default configuration needs a table named
for the Symbol specified (e.g. MSFT), with
column names date,o,h,l,c,v,a. For table
layout changes it is best to use
setDefaults(getSymbols.MySQL,...)
with
the new db.fields values specified.
Jeffrey A. Ryan
MySQL AB https://www.mysql.com
Jeroen Ooms and David James and Saikat DebRoy and Hadley Wickham and Jeffrey Horner (2019). RMySQL: Database Interface and 'MySQL' Driver for R. https://CRAN.R-project.org/package=RMySQL
R-SIG-DB. DBI: R Database Interface
## Not run: # All 3 getSymbols calls return the same # MSFT to the global environment # The last example is what NOT to do! setDefaults(getSymbols.MySQL,user='jdoe',password='secret', dbname='tradedata') ## Method #1 getSymbols('MSFT',src='MySQL') ## Method #2 setDefaults(getSymbols,src='MySQL') # OR setSymbolLookup(MSFT='MySQL') getSymbols('MSFT') ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.MySQL('MSFT',env=globalenv()) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.