I've deployed an R Shiny app on a R Studio Connect Server and I'm simply trying to get data from a SQLite database which I've included in the deployed application.
When I run the app locally (through the runApp function), everything works fine and the data is fetched from the database.
When I run the app from the R Studio Connect Server, I have the following error message: "Warning: Error in : database is locked" I do not understand why the db is locked or how to unlock it.
The tree of the deployed application looks like this
- app.R
- data/
|-- database.db
The code of my shiny app is as follows:
library(dplyr)
library(shiny)
library(RSQLite)
loadData <- function() {
path_to_db <- "data/database.db"
# Connect to the database
db <- dbConnect(SQLite(), path_to_db)
# Construct the fetching query
isin_static_info_tb = "isin_static_info_table"
query <- sprintf("SELECT * FROM %s", isin_static_info_tb)
# Submit the fetch query and disconnect
data <- dbGetQuery(db, query)
dbDisconnect(db)
data
}
# Define UI for application that draws a histogram
ui <- fluidPage(
actionButton(inputId = "displayTable", label = "Show table"),
tags$hr(),
tableOutput(outputId = "table")
)
# Define server logic required to draw a histogram
server <- function(input, output) {
data <- eventReactive(input$displayTable, {
return(loadData())
})
output$table <- renderTable(data())
}
# Run the application
shinyApp(ui = ui, server = server)