How to make Shiny reactivity work with SQL database?
问题 Alright, I modified the script following @Pork Chop advice: server.R library(shiny) library(DT) library(RMySQL) con <- dbConnect(MySQL(), user="myuser", host="myhost", dbname="mydb") shinyServer(function(input, output) { sqlOutput <- reactive({ sqlInput <- paste0("select * from mydb.mytable", " where value < ", input$value, ";") dbGetQuery(con, sqlInput) }) output$table <- DT::renderDataTable(sqlOutput(), server=TRUE, rownames=FALSE, filter="top", options=list(pageLength=10)) output$download