mercredi 7 octobre 2015

Error in sqliteSendQuery(con, statement, bind.data) : expired SQLiteConnection

I am trying to build a shiny application, with the first Drop down menu populated from a SQLite using renderUI.

Below is my server.r

library("shiny")
library("RSQLite")

shinyServer(function(input, output) {


db<-dbConnect(SQLite(),"PNL.sqlite")


origins<-data.frame(dbGetQuery(db,"SELECT Origin_Name from CNS_Origin_List"))

output$origin<-renderUI({
  selectInput(inputId = "origin",label = "Select Origin",choices = origins$Origin_Name)
})


query<-reactive({
                 sql<-dbGetQuery(db,paste0('SELECT Region_Name from CNS_Origin_List Where Origin_Name ="',input$origin,'"'))
})





#This is where the error occurs when I call the query()
output$region<-renderTable(query())


dbDisconnect(db)
})

Here is my ui.R

library(shiny)

# Define UI for application that draws a histogram
shinyUI(fluidPage(

  # Application title
  titlePanel("PNL Calculator!"),

  # Sidebar with a slider input for the number of bins
  fluidRow(
    column(4,
           wellPanel(
             uiOutput(outputId = "origin"))),

    column(6,
           wellPanel(
             tableOutput(outputId = "region"),

           )
           )
    )

))

here is the dropdown of origins

I get

Error in sqliteSendQuery(con, statement, bind.data) : 
  expired SQLiteConnection

Not sure where I am going wrong. Please help

Aucun commentaire:

Enregistrer un commentaire