R brilliant RODBC connection

I have a brilliant R application that runs locally, but when I download it, I get an error message:

 first argument is not an open RODBC channel

Here is my code:

conn<- suppressWarnings( odbcDriverConnect('driver={SQL Server};server=SWDCH;    database=GR;    trusted_connection=yes;uid=RUser , pwd=ruser'))
  data <- sqlQuery(conn,paste("exec Performance  @MetricType = '", MetricType ,"',@Metric = '", Metric ,"',   @Market = '", Market  , "', @StartDate = '", StartDate, "', @EndDate = '", EndDate, "';",sep =""),errors=FALSE)

I think the problem is with the conn object, but any idea what the problem is?

+4
source share
1 answer

I had an identical problem, which is now resolved on my part. Let me know if this works for you.

The problem is that this is the default connection that is referenced via Shiny. I ran the following code that works locally, but gave me the same "RODBC connection not open" error as you

Shiny:
tdConnection2 < - odbcConnect ( "my_dsn", eid = "ABC123", pw = "" ) results < - sqlQuery ( " SQL" )

, , tdQuery()

Shiny:
tdConnection2 < - odbcConnect ( "my_dsn", eid = "ABC123", pw = "" ) results < - sqlQuery (channel = tdConnection2, query = " SQL" )

, , print (tdConnection2), , . rPython - python , R, / , Shiny. , .

+1

Source: https://habr.com/ru/post/1537927/


All Articles