Rsession ends when writing with rsqlite in standalone shiny mode

23 views
Skip to first unread message

Stephane Plaisance

unread,
Sep 1, 2020, 3:42:50 AM9/1/20
to Shiny - Web Framework for R
When I click the button to overwrite a sqlite file on the local /Data from the standalone shiny App (in chrome on my server) the session dies 
BUT
It all works fine and the session continues when I run the same app under RStudio running on the same server and using the button ('Run App').

I opened a ticket on stackoverflow with my code and more details (https://stackoverflow.com/questions/63673945/shiny-session-dies-when-run-from-server)

I suspect these code blocks to do the mess

* my function to write the file

createDB <- function(filepath, filename, dbfile){
  data <- read_csv(filepath, 
                      locale = locale(encoding = "ISO-8859-2",
                                      asciify = TRUE))
  # give proper english names to columns
  colnames(data) <- names
  data$Email <- tolower(data$Email)
  version <- data.frame(version=filename)
  
  # create sqlite and save
  mydb <- dbConnect(RSQLite::SQLite(), dbfile)
  dbWriteTable(mydb, "data", data, overwrite=TRUE)
  dbWriteTable(mydb, "version", version, overwrite=TRUE)  
  dbDisconnect(mydb)
}

* the reactive code for the button 

  observeEvent(input$Upload, { 
  if(is.null(input$Browse)) { 
    return(NULL) 
  } else { 
    file <- input$Browse createDB(file$datapath, basename(file$name), dbfile)
    shinyalert(paste(basename(file$name), 
                  "database uploaded, please refresh the session", sep=" "), 
                  type = "success", timer=2000) 
})

Please let me know if I need to replicate the code here as some sites do. not like replication.

Thanks in advance for your help

Stephane Plaisance

unread,
Sep 2, 2020, 9:45:22 AM9/2/20
to Shiny - Web Framework for R
#missing
library("readr")
Reply all
Reply to author
Forward
0 new messages