Problem to upload form responses in Shiny to a MySQL database

Hello and thanks for reading me. I am a bit desperate, since I am trying to make an app in shiny in which I can make a form and that the responses are saved within a MySQL database hosted on AWS. I've been doing some research and came across some code about it, but so far I haven't gotten it to work properly and I'm not sure what the problem is. Anyone have any ideas? I wish they could help me

The code that I have so far is the following:

ui.R <- shinyUI(
      column(2,selectInput("task1", label=NULL,
                           choices = c(0:5), 
                           selected = 0))

Sys.setlocale(category = "LC_ALL", locale = "Mexico")

server.R<-shinyServer( ##here
      # Take a dependency on input$uploadMarks
      if(input$uploadMarks==0) return()
      #Use isolate() to avoid dependency on input$task1

  ui={ ui.R},
  server =  {
    # function to connect to MySQL database and sending query of INSERT
    writingMarks <- function(basesSMI,ICD_34618,valueToInsert){
      courseDB <- dbConnect(MySQL(), user="admin", password="Nikogta4", 
                            host="", db=basesSMI)
      query <- paste("INSERT INTO `",basesSMI,"`.`ICD_34618","ICD_34618",
                     "` values (","( Avance",")",sep="")
      dbSendQuery(conn=courseDB, query)
      connections <- dbListConnections(MySQL())
      for(i in connections) {dbDisconnect(i)}

And I am having the following error when running the app:

Warning: Error in .local: could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.1.6A) Avance)' at line 1
  60: .local
  59: dbSendQuery
  57: writingMarks [#10]
  44: <observer> [#8]
   1: runApp

Additionally, I have attached a screenshot of how the database looks in MySQL, maybe it could be useful:

Thanks for reading me. hopefully someone can support me in this regard

first of all, I would recommend not doing anything in shiny that you can't yet do comfortably in an R script.
your paste statement result looks like this
(assuming basesSMI has some text like "something")

"INSERT INTO `something`.`ICD_34618ICD_34618` values (( Avance)"

I think this isnt valid SQL. What are you trying to do ? when you call writingMarks you are using an undeclared ICD_34618 object to pass in as a param, (which wont work..) ? but you dont make use of it withing the function body, you have some repeated strings of it.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.