Hello,
I am having a hard time trying to code a Shiny app that lets the user upload a file and then with a Button it is supposed to create a new table on a Database that's connected through RSQLite, please see code below:
ui.R:
navbarPage(
"Ingreso de Data a Base de Datos",
fileInput('file1', 'Choose xlsx file',
accept = c(".xlsx")
),
actionButton("Load_DB_Button",
"Load Data",
style = "bordered",
width = "100%"),
mainPanel(
tableOutput('contents'))
)
Server.R:
Load_Data <- source("Load_Data.R")
library(readxl)
function(input, output, session){
output$contents <- renderTable({
req(input$file1)
inFile <- input$file1
read_excel(inFile$datapath, 1)
})
vals <- reactiveValues()
observeEvent(input$Load_DB_Button,{
vals$Load_Data_Out <- Load_Data()
showModal(modalDialog("Calculation Finished!"))
})
}
Load_Data.R:
library(RSQLite)
library(dplyr)
function(){
BD_CA_IDAAN <- DBI::dbConnect(RSQLite::SQLite(), "C:/Users/CBarrios/Desktop/Ex_Files_Data_Apps_R_Shiny/Exercise Files/07_03/Database/DB_CA_IDAAN.db")
df1 <- data.frame(contents)
dbWriteTable(BD_CA_IDAAN, "Test Table", df1)
message("Running Code")
return("Some Output")
}
I just need it to create a Table on the Database with the data that was loaded through Excel. Any help will be appreciated.