【发布时间】:2015-10-20 12:46:55
【问题描述】:
引用以下示例:http://www.r-bloggers.com/a-shiny-example-sap-hana-r-and-shiny/
在以下示例中,他们在获得所需的表后运行odbcClose(ch)。将表加载到工作区后使用odbcClose(channel) 是一种好习惯吗?在Shiny 应用程序中使用 SQL 连接时应该做些什么不同的事情吗?
library("shiny")
library("RODBC")
ch<-odbcConnect("HANA_TK",uid="SYSTEM",pwd="manager")
odbcQuery(ch,"SELECT table_name from SYS.CS_TABLES_ where schema_name = 'SFLIGHT'")
tables<-sqlGetResults(ch)
**odbcClose(ch)**
shinyUI(pageWithSidebar(
headerPanel("SAP HANA and R using Shiny"),
sidebarPanel(
selectInput("Table", "Choose a table:",
choices = tables$TABLE_NAME),
numericInput("Records", "Number of Records to view:", 10)
),
mainPanel(
tableOutput("view")
)
))
【问题讨论】: