How to save multiple rows of data in MySQL server from R Shiny? The following codes are only applicable for a single row:
saveData <- function(data ) {
db <- dbConnect(MySQL(), dbname = "my_servername", host = options()$mysql$host,
port = options()$mysql$port, user = options()$mysql$user,
password = options()$mysql$password)
query <- sprintf(
"INSERT INTO %s (%s) VALUES ('%s')",
"my_Table",
paste(names(data), collapse = ", "),
paste(data, collapse = "', '")
)
dbGetQuery(db, query)
dbDisconnect(db)
}
Looking for a help from expert. Thanks