I am trying to read a table from MySQL, I have loaded the file in "ts"
database, in table name ACC. but i am unable to read it in R through
getSymbol function.
mysql> show databases;
+--------------------------------+
| Database |
+--------------------------------+
| information_schema |
| mysql |
| test |
| ts |
+--------------------------------+
mysql> use ts;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_ts |
+--------------------+
| ACC |
+--------------------+
mysql> select * from ACC;
+------------------------------+------------+---------+-------------+------------+-------------+
| Date | Open | High | Low | Close |
Volume |
+------------------------------+------------+---------+-------------+------------+-------------+
| 2006-11-30 09:55:00 | 1140 | 1150 | 1140 | 1150 | 33
|
| 2006-11-30 09:56:00 | 1149.9 | 1153 | 1149.9 | 1150 | 3195 |
| 2006-11-30 09:57:00 | 1148 | 1150 | 1147 | 1147.25 | 3669 |
| 2006-11-30 09:58:00 | 1148 | 1148 | 1145.45 | 1146 | 1982 |
I created the database after becoming super user, without user name and
password,
up-till here everything is fine.
library(quantmod)
library(RMySQL)
con <- dbConnect("MySQL",dbname ="ts")
data <- dbReadTable(con,"ACC")
tdata=(xts(data[,-1], as.POSIXct(data[,1])))
*barChart(tdata)*
dbDisconnect(con)
This thing works fine. I mean if done through DBI and RMySQL basic command,
then table
get read properly and I get a wonderful chart.
But doing it through getSymbol is giving problem.
*first i tried *
setDefaults(getSymbols.MySQL, dbname='ts')
getSymbols('ACC',src='MySQL')
Error in getSymbols.MySQL(Symbols = "ACC", env = <environment>,
verbose FALSE, :
At least one connection argument ( ‘user’ ‘password’ ‘dbname’ ) is not set
*second i tried *
setDefaults(getSymbols.MySQL,user=' ',password='
',dbname='ts')
getSymbols('ACC',src='MySQL')
Error in mysqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not run statement: Unknown column 'o' in
'field
list')
*third i tried this *
setDefaults(getSymbols.MySQL,user='', password='',
dbname='ts',
db.fields=c("Date","Open","High","Low","Close","Volume"))
getSymbols('ACC',src='MySQL')
Error in mysqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not run statement: FUNCTION ts.c does not exist)
I know i am doing something wrong but, i am really not able to figure out
what and where.
Please help me.
[[alternative HTML version deleted]]