Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(shiny)
- library(DBI)
- library(pool)
- pool <- dbPool(drv = RMySQL::MySQL(),dbname = "database",host = "localhost",username = "username",password = "password", port = 3306, unix.sock = "/var/run/mysqld/mysqld.sock")
- ui <- fluidPage(
- uiOutput("names")
- )
- server <- function(input, output, session){
- getNames <- function(x){
- dbGetQuery(x, "SELECT DISTINCT names from dummyTable;")
- }
- refreshData <- reactive({
- invalidateLater(60000, session)
- getNames(pool)
- })
- output$names <- renderUI({
- selectInput(inputId = "name", label = "First names", choices = c(as.character(refreshData()[,1])))
- })
- }
- shinyApp(ui, server)
Add Comment
Please, Sign In to add comment