简体   繁体   English

无法通过Shinyapps.io连接到ODBC

[英]Unable to connect to ODBC through shinyapps.io

I build ar shiny app which uses the odbc library to fetch the data from server hosted in public server and shows the result output. 我构建了一个闪亮的应用程序,该应用程序使用odbc库从公共服务器中托管的服务器中获取数据并显示结果输出。 It is working perfectly under Win10. 它在Win10下运行良好。

I am using the below code to connect to server: 我正在使用以下代码连接到服务器:

library(odbc)
con <- dbConnect(odbc(),
                 Driver = "SQL Server Native Client 11.0",
                 Server = "****",
                 Database = "****",
                 UID = "****",
                 PWD = "****")

When I hosted the app in www.shinyapps.io it is not working. 当我在www.shinyapps.io上托管该应用程序时,它无法正常工作。 It shows the error as below: 它显示错误如下:

Warning: Error in : nanodbc/nanodbc.cpp:950: 01000: [unixODBC][Driver Manager]Can't open lib 'SQL Server Native Client 11.0' : file not found 

I am unable to why it says 'file not found'? 我无法解释为什么显示“找不到文件”? The app works perfectly when I run the app using rstudio from my PC. 当我在PC上使用rstudio运行该应用程序时,该应用程序可以完美运行。

Please help. 请帮忙。 Thanks in advance. 提前致谢。

Sumanta Sumanta

You have to use FreeTDS. 您必须使用FreeTDS。 I found either using 7.4 or 7.0 version. 我发现使用7.4或7.0版本。

try this using odbc: 使用odbc尝试一下:


    library(DBI)
    library(odbc)

    con <- dbConnect(
      odbc(),
      Driver      = "FreeTDS",
      Database    = database,
      Uid         = uid,
      Pwd         = pwd,
      Server      = server,
      Port        = 1433,
      TDS_Version = 7.4
    )

or this usind rodbc: 或这个usind rodbc:

    library(RODBC)

    con <- odbcDriverConnect(
      'Driver=FreeTDS;
      TDS_Version=7.4;
      Server=<server>;
      Port=<port>;
      Database=<db>;
      Uid=<uid>;
      Pwd=<pw>;
      Encrypt=yes;
      TrustServerCertificate=no;
      Connection Timeout=30;')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM