有没有办法从ODBC数据库中获取反应函数之外的数据?我在很多例子中看到过,但当查询超出被动反应时,我似乎无法获取数据?
Server.R
library(shiny)
library(RODBC)
library(dplyr)
LIMS <- odbcConnect(dsn = "LIMS", uid="unit", pwd="unit",readOnlyOptimize = TRUE)
first <-sqlQuery(LIMS,paste("SELECT ID_NUMERIC, ANALYSIS, SAMPLE_NAME, SAMPLED_DATE, COMPONENT_NAME, DATE_COMPLETED, RESULT_TEXT FROM SAMP_TEST_RESULT WHERE (ANALYSIS LIKE '%85W%')"),dec=getOption("dec"))
odbcClose(LIMS)
shinyServer(function(input, output){
output$chart <- renderDataTable({first()})
output$downloadData <- downloadHandler(
filename = function() {
paste('data_', Sys.Date(), '.csv', sep="")
},
content = function(file) {
write.csv(final(), file)
})
UI.R
library(shiny)
library(RODBC)
shinyUI(fluidPage(
titlePanel("Data Visualization Tool",
tags$head(
tags$img(src="logo.jpg", height="150px",width="150px",align="right")
)),
column(width=10,
mainPanel(tabsetPanel(
tabPanel("Chart",htmlOutput("chart1"),align="left"),
tabPanel("Table",dataTableOutput("chart"),align="left",downloadLink('downloadData', 'Download')),
))
)))
)
))
错误:
> shiny::runApp()
Listening on http://127.0.0.1:6116
Warning: closing unused RODBC handle 5
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer
ERROR: [on_request_read] connection reset by peer