Search code examples
rshinyrodbcshiny-reactivity

Refresh selectInput on shiny DropDownList retrieved from RODBC


I have a reactive input in ShinyUI Tab1:

selectInput("SelectVar", choices = DropDownListForVar())

,where

DropDownListForVar()) = function (){
    sqlQuery = return ( Connection, "Select var from dbo.Variables")
} ## using RODBC library

In my shiny app, I am also updating the dbo.Variables table from a Tab2. The problem is that I cannot see the updated value in dbo.Variables from Tab1, unless I restart the app.

Any ideas?


Solution

  • It is hard to debug without a reproducible example. My guess is that you lack the reactive context for selectInput or data retrieval. Please make sure to update the dropdown using updateSelectInput and fetch the data with a reactive expression, both inside server. Additionally, to achieve this goal, you need to inform your Shiny App automatically when the database is updated, which could be hard to implement. I would suggest triggering queries with an action button or timer (reactiveTimer)