Guest User

Untitled

a guest
Oct 24th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. library(shiny)
  2. library(DBI)
  3. library(pool)
  4. pool <- dbPool(drv = RMySQL::MySQL(),dbname = "database",host = "localhost",username = "username",password = "password", port = 3306, unix.sock = "/var/run/mysqld/mysqld.sock")
  5.  
  6. ui <- fluidPage(
  7. uiOutput("names")
  8. )
  9.  
  10. server <- function(input, output, session){
  11. getNames <- function(x){
  12. dbGetQuery(x, "SELECT DISTINCT names from dummyTable;")
  13. }
  14.  
  15. refreshData <- reactive({
  16. invalidateLater(60000, session)
  17. getNames(pool)
  18. })
  19. output$names <- renderUI({
  20. selectInput(inputId = "name", label = "First names", choices = c(as.character(refreshData()[,1])))
  21. })
  22. }
  23.  
  24. shinyApp(ui, server)
Add Comment
Please, Sign In to add comment