I created an online experiment with a brilliant package for R. Let's say I have 3 reactive values called βquitβ, βdecisionβ and rating .
In addition, I launched the MySQL database on the Amazon RDS web service. MySQL Version 5.6.22 .
I managed to send non-reactive values ββ- as a timestamp - to the MySQL database. Therefore, I guess the problem is where to find the code that speaks MySQL in Server.R code. For non-reactive values, it works fine when the code is outside the (before) reactive server function. But with reactive values, I suppose it should be somewhere inside.
I tried this code:
Server.R library(shiny) library(RMySQL) library(DBI) con <- dbConnect(MySQL(), dbname="db", username="myname", password="mypassword", host="myhost.com", port=xxxx) function(input, output, session){ sql <- reactive({ paste("insert into scenario1 (toss, dec, rat, timestamp) values (",input$toss,",",input$decision,",",input$rating,"now())") }) result<-reactive({dbSendQuery(con, sql())}) }
This way I am not getting an error message. So maybe the error is in the insert into code.
Also, I'm not sure if the packages I used are ideal for this purpose. I've tried a lot. Whenever I add a reactive value, leaving it outside the SQL quote, it stops working. I'm starting to think that RMySQL does not have this feature. There is nothing in the manual about insert into .
Can anyone spot the mistake I made?
source share