I have this column “timestamp” in table A, and I want to select all data but the last week, here is my R code but an error pop up saying “Error in function (classes, fdef, mtable) :
unable to find an inherited method for function “dbWriteTable”, for signature “MySQLConnection”, “data.frame”, “character””, any help would be appreciated? THANK YOU.
fun <- function(con, dat.set, tbl.name) {
if (dbExistsTable(con, tbl.name)) {
BFWeek = dbGetQuery(con, statement=paste("SELECT * FROM A",
"WHERE timestamp < timestampadd(day, -7, now())"))
dbWriteTable(con, BFWeek, tbl.name, row.names=F, append=T);
} else {
dbWriteTable(con, tbl.name, dat.set, row.names=F, append=T);
}
}
fun(conn_table, df, "A")
The name of the table has to come before the data frame you want to write to that table. In the
elsepart of your code, you seem to have the order correct, but in theifpart you haveBFWeekbeforetbl.namewhere it should go after.This would have given you an idea as to which methods are available and which are not.