shiny and SQL server are linked.
We succeeded in specifying search conditions by input from shiny.
Isn't it possible to select the column names to be obtained in this way in the output from shiny?
ui.R
shinyUI(
fluidPage(
selectInput("select","select", choices = c("CountryCode","District","NAME")),
textInput("ID","ID"),
actionButton("go", "go"),
tableOutput("table"),
tableOutput("tablee")
)
)
server.R
shinyServer(function(input, output) {
observeEvent(input$go,{
output$table <- renderTable({
sql <- 'SELECT ?select FROM City;'
query <- sqlInterpolate(pool, sql, select = input$select)
dbGetQuery(pool, query)
})
})
output$tablee <- renderTable({
sql <- "SELECT * FROM City WHERE ID = ?ID;"
query <- sqlInterpolate(pool, sql, ID = input$ID)
dbGetQuery(pool, query)
})
})
global.R
library(shiny)
library(DBI)
library(pool)
pool <- dbPool(
drv = RMySQL::MySQL(),
dbname = "shinydemo",
host = "shiny-demo.csa7qlmguqrf.us-east-1.rds.amazonaws.com",
username = "guest",
password = "guest"
)