I am trying to set up a MySQL database in R. I've installed RMySQL and set up a connection successfully. I was able to use the dbWriteTable()
function successfully as well, but when I try to use dbListTables()
it gives me an error saying
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘dbListTables’ for signature ‘"missing"
Can anyone shed some light on this? Heres the code:
#Install and load Quandl package
install.packages("Quandl")
library(Quandl)
#Install and load SQL package
install.packages("RMySQL")
library(RMySQL)
#Authenicate API key
Quandl.api_key("________")
#Load top 10 biggest Healthcare compaines in Fortune 500 according to
#http://fortune.com/2015/06/20/fortune-500-biggest-healthcare-companies/
CVS <- Quandl("WIKI/CVS")
McKesson <- Quandl("WIKI/MCK")
UnitedHealthGroup <- Quandl("WIKI/UNH")
AmerisourceBergern <- Quandl("WIKI/ABC")
ExpressScriptsHolding <- Quandl("WIKI/ESRX")
CardinalHealth <- Quandl("WIKI/CAH")
Walgreens <- Quandl("WIKI/WBA")
Johnson_Johnson <- Quandl("WIKI/JNJ")
Anthem <- Quandl("WIKI/ANTM")
Aetna <- Quandl("WIKI/AET")
con <- dbConnect(MySQL(),
user = 'root',
password = 'password',
dbname = 'mysql')
dbWriteTable(con, value = Aetna, name = "Aetna")
dbListTables()
I see what I was doing wrong. I was not providing the connection variable con
to the dbListTables()
function. I tried dbListTables(con)
and it works just fine.