I really need help( I've tried a lot of different cases and searched a lot of forums and tutorials(( The aim is simple: I have some MySQL database and table in it. I want to insert values from shiny input into that table. I need actionButton instead submitButton, because there is another important part of my app with live update. Also, I've tried the part of code away from Shiny, and everything worked. So, the problem is in Shiny commands, but I do not know in what. Here is the part of my code (I've deleted almost everything and left just one selectInput field and actionButton):
server.R
library(shiny)
library(RMySQL)
# function to connect to MySQL database and sending query of INSERT
writingMarks <- function(course,homework,valueToInsert){
courseDB <- dbConnect(MySQL(), user="root", password="password",
host="111.111.111.1", db=course)
query <- paste("INSERT INTO `",course,"`.`homework",homework,
"` values (",rowToInsert,")",sep="")
dbSendQuery(conn=courseDB, query)
connections <- dbListConnections(MySQL())
for(i in connections) {dbDisconnect(i)}
}
shinyServer(
function(input,output,session){
# here I've put "mathematics", "1", "test" instead my input variables
output$uploadMarks <-
reactive({writingMarks("mathematics","1","test")})
}
)
ui.R
library(shiny)
shinyUI(fluidPage(
fluidRow(
column(2,selectInput("task1", label=NULL,
choices = c(0:5),
selected = 0))
),
actionButton("uploadMarks","Занести оценки в журнал")
)
)