How to make shinyapps.io connect to Microsoft sql server with RODBC work?

2,957 views
Skip to first unread message

Nion Cao

unread,
Sep 26, 2015, 8:05:30 AM9/26/15
to ShinyApps Users
My shinyapp connect to a remote microsoft sql server. shinyapp work well on my windows pc. However after I deployed my app to shinyapps.io. It did not work. It show the error message below. I guess the reason is the instance of shinyapps.io is linux OS. 

RODBC need unixODBC and freedts installed to make R connect to microsoft sql server. 

However I dont know how to install unixODBC on shinyapps.io. anybody know how to do it ? any alternative way to make my app which hosted in shinyapps.io works.

The following is the error log. thanks



Warning in odbcDriverConnect("driver={SQL Server};Server=xxx.xxx.xxx.xxx;database=abc;uid=xxdb;pwd=xxpwd") :
2015-09-26T04:12:01.158391+00:00 shinyapps[61748]:   [RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified

2015-09-26T04:12:01.159005+00:00 shinyapps[61748]:   ODBC connection failed
2015-09-26T04:12:01.169780+00:00 shinyapps[61748]: Error in sqlQuery(dbhandle, sql) : 
2015-09-26T04:12:01.169783+00:00 shinyapps[61748]:   first argument is not an open RODBC channel

Andy Kipp

unread,
Sep 28, 2015, 10:31:06 AM9/28/15
to Nion Cao, ShinyApps Users
Nion,

shinyapps.io already has the FreeTDS driver installed. But for your app to work on shinyapps.io, you will need to change your ODBC connect string to use it:

When running on shinyapps.io you will to use the "FreeTDS" driver:

odbcDriverConnect("driver=FreeTDS; ...")

You should also be sure to confirm that your database server is accessible from the shinyapps.io servers. This may require adjusting your firewall rules to allow connections from shinyapps.io.

-Andy

--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/7f54933b-fefc-4ef7-9ddb-31a364f48fd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Psaris-Weis

unread,
Feb 26, 2016, 3:46:17 PM2/26/16
to ShinyApps Users
Hi, I'm running into a similar issue. My connection string is using FreeTDS, but is getting the following error:

[RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source


Here's my connection string:

odbcDriverConnect('Driver=FreeTDS;Server=myservername;Database=dbname;Uid=myuid;Pwd=mypwd;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;')

Any words of advice? I believe the shinyapps.io ip addresses are whitelisted in the sql database firewall. Is there a way for me to test whether this was done successfully though?

Andy Kipp

unread,
Feb 29, 2016, 10:39:03 AM2/29/16
to Mike Psaris-Weis, ShinyApps Users
I would double check those firewall settings. Your connection string looks fine assuming your server name is valid.

Mike Psaris-Weis

unread,
Feb 29, 2016, 1:40:08 PM2/29/16
to Andy Kipp, ShinyApps Users
The firewall settings are correct. We whitelisted these IP addresses:

54.204.29.251
54.204.34.9
54.204.36.75
54.204.37.78

I made some edits to the connection string, and now am getting a different error:

Connection string:

old:   odbcDriverConnect('Driver=FreeTDS;Server=myservername;Database=dbname;Uid=myuid;Pwd=mypwd;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;')
new: odbcDriverConnect('Driver={FreeTDS};Server=tcp:myservername,myportnumber;Database=dbname;Uid=myuid;Pwd={mypassword};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;')

Error:

[RODBC] ERROR: state IM002, code 0, message [unixODBC][Driver Manager]Data source name not found, and no default driver specified

I've run this locally on my windows machine with the correct driver and it connects fine. I've done some googling and found some posts mentioning that the odbc.ini and odbcinst.ini files need to be set up to point to the correct drivers. Could this have something to do with it? 




--

Andy Kipp

unread,
Feb 29, 2016, 2:19:10 PM2/29/16
to Mike Psaris-Weis, ShinyApps Users
Well I think you definitely don't want the braces in the driver name. You shouldn't need the ODBC DSN configured as long as you have all the driver information listed as you do. 

Are you using an IP address or hostname for your servername?

Wim Jansen

unread,
May 4, 2016, 11:49:38 AM5/4/16
to ShinyApps Users, mike....@gmail.com
I'm also having problems with connecting to an azure database. I'm using the following script:

s_driver.name <- "FreeTDS"
s_server
.name <- "xxxxxxx.database.windows.net,1433"
s_db
.name <- "xxxxxxx"
s_user
.name <-"xxxxxxx"
s_pwd
<- "xxxxxxx"

s_con
.text <- paste("DRIVER=",s_driver.name,
                   
";Server=",s_server.name,
                   
";Database=",s_db.name,
                   
";UID=", s_user.name,
                   
";PWD=",s_pwd,
                   
";Encrypt=yes;",
                   
"Connection Timeout = 30;",
                    sep
="")

rodbc_connection
<- odbcDriverConnect(s_con.text, case="nochange")
s_query
<- 'select distinct x from y order by z desc'
v_output
<- sqlQuery(rodbc_connection , s_query)
odbcCloseAll
()

This results in the following errors in the logfile after opening the app:


2016-05-04T15:41:15.461535+00:00 shinyapps[99921]: [RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source 2016-05-04T15:41:15.461683+00:00 shinyapps[99921]: [RODBC] ERROR: state 01000, code 20002, message [unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed 2016-05-04T15:41:15.461822+00:00 shinyapps[99921]: Warning in odbcDriverConnect(s_con.text, case = "nochange") : 2016-05-04T15:41:15.461824+00:00 shinyapps[99921]: [RODBC] ERROR: state 01000, code 20017, message [unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server 2016-05-04T15:41:15.462233+00:00 shinyapps[99921]: Warning in odbcDriverConnect(s_con.text, case = "nochange") : 2016-05-04T15:41:15.462246+00:00 shinyapps[99921]: ODBC connection failed 2016-05-04T15:41:15.463368+00:00 shinyapps[99921]: Warning: Error in sqlQuery: first argument is not an open RODBC channel 2016-05-04T15:41:15.469177+00:00 shinyapps[99921]: Stack trace (innermost first): 2016-05-04T15:41:15.232456+00:00 shinyapps[99921]: as.Date, as.Date.numeric 2016-05-04T15:41:15.461532+00:00 shinyapps[99921]: Warning in odbcDriverConnect(s_con.text, case = "nochange") : 2016-05-04T15:41:15.461681+00:00 shinyapps[99921]: Warning in odbcDriverConnect(s_con.text, case = "nochange") : 2016-05-04T15:41:15.469187+00:00 shinyapps[99921]: 9: tryCatchList 2016-05-04T15:41:15.469188+00:00 shinyapps[99921]: 8: tryCatch 2016-05-04T15:41:15.469189+00:00 shinyapps[99921]: 7: connect$retry 2016-05-04T15:41:15.469190+00:00 shinyapps[99921]: 6: eval 2016-05-04T15:41:15.469183+00:00 shinyapps[99921]: 11: doTryCatch 2016-05-04T15:41:15.469193+00:00 shinyapps[99921]: 4: eval 2016-05-04T15:41:15.469185+00:00 shinyapps[99921]: 10: tryCatchOne 2016-05-04T15:41:15.469182+00:00 shinyapps[99921]: 12: fn 2016-05-04T15:41:15.469179+00:00 shinyapps[99921]: 50: sqlQuery 2016-05-04T15:41:15.469181+00:00 shinyapps[99921]: 13: runApp 2016-05-04T15:41:15.469394+00:00 shinyapps[99921]: Error in sqlQuery(rodbc_connection, s_query) :


I've whitelisted the following ip's in the firewall of the database: 
  • 54.204.29.251
  • 54.204.34.9
  • 54.204.36.75
  • 54.204.37.78
Does anybody have an idea how to fix this?

Mike Psaris-Weis

unread,
May 4, 2016, 12:10:12 PM5/4/16
to Wim Jansen, ShinyApps Users
Hi Wim,

Andy Kipp helped me figure this out. The connection string needs to include a TDS_Version, like this:

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

If this doesn't work, try TDS_Version=9.0.

Hope this helps,

~Mike

Wim Jansen

unread,
May 9, 2016, 2:57:41 AM5/9/16
to ShinyApps Users, wimj...@outlook.com
Thank you Mike, it worked using "TDS_Version=7.0".

Op woensdag 4 mei 2016 18:10:12 UTC+2 schreef Mike Psaris-Weis:

Justin Nafe

unread,
Jul 25, 2016, 5:57:27 PM7/25/16
to shinyapps.io Users
I have a Microsoft SQL database within Azure and can't seem to make a connection after publishing to shinyapp.io. I get the error: "first argument is not an open RODBC channel"

I've whitelisted the following IP at the firewall settings within Azure:
54.166.122.218
54.162.168.48
54.204.29.251
54.204.37.78
54.204.34.9
54.204.36.75

I've tried using the following, and all return the save error after publishing to shinyapp.io
odbcDriverConnect(connection = "Driver=FreeTDS;Server=tcp:mydns.database.windows.net,1433;Database=mydatabase;Uid=myuserid;Pwd=mypass;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;")
 odbcDriverConnect(connection = "Driver=FreeTDS;TDS_Version=7.0;Server=tcp:mydns.database.windows.net,1433;Database=mydatabase;Uid=myuserid;Pwd=mypass;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;")
 odbcDriverConnect(connection = "Driver=FreeTDS;TDS_Version=7.2;Server=tcp:mydns.database.windows.net,1433;Database=mydatabase;Uid=myuserid;Pwd=mypass;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;")
 odbcDriverConnect(connection = "Driver=FreeTDS;TDS_Version=9.0;Server=tcp:mydns.database.windows.net,1433;Database=mydatabase;Uid=myuserid;Pwd=mypass;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;")
 
 I also tried specifying the port with Port=1433 instead of .net,1433 and tried all versions above with it but to no avail.

Does anyone have any more suggestions or ideas?

I think that more and more enterprises are starting to use Azure, and Azure is steadily adding support for R (even within SQL databases), so I hope that connecting to MS SQL database is supported within Shinyapps.io.

Joshua Spiewak

unread,
Jul 27, 2016, 3:49:05 PM7/27/16
to shinyapps.io Users
I haven't tried this on Azure yet, perhaps tomorrow.

But I was able to connect to an AWS RDS Sql Server instance when I ran my shiny app locally via an SSH tunnel, and then changed the hostname from localhost to the actual server name and was able to connect from the app when deployed to shinyapps.io, using this:

odbcDriverConnect(connection = "Driver=FreeTDS;Server=blahblahblah.us-east-1.rds.amazonaws.com;Port=1433;Database=master;Uid=user;Pwd=password;")

Are you getting the error on the odbcDriverConnect line, or afterward when trying to use it?
What do your logs show?
How long is the app up and running when the error occurs?

Justin Nafe

unread,
Jul 28, 2016, 6:52:39 PM7/28/16
to shinyapps.io Users
I'm getting the error on the line after, sqlQuery command where the first parameter is the connection from the odbcDriverConnect result.

The logs show:
[RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[RODBC] ERROR: state 01000, code 20013, message [unixODBC][FreeTDS][SQL Server]Unknown host machine name.

In Azure, we can set allowed IP address to access the database. I opened it up all the way... set start IP to 0.0.0.0 to end ip address 255.255.255.255 but I still get the same errors.

When I removed the "tcp:" from the beginning of the "Server" and move the port to Port=1433 syntax instead of ",1433", I got the following errors:
[RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[RODBC] ERROR: state 01000, code 20002, message [unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[RODBC] ERROR: state 01000, code 20017, message [unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server

Still no luck yet.

Justin Nafe

unread,
Jul 29, 2016, 10:22:22 AM7/29/16
to shinyapps.io Users
I decided to randomly guess at setting TDS_Version, and TDS_Version=8.0 ended up working for me! (unless something happened behind the scenes on shinyapps.

The final connection request that worked was:
odbcDriverConnect(connection = "Driver=FreeTDS;TDS_Version=8.0;Server=mydns.database.windows.net;Port=1433;Database=mydatabase;Uid=myuserid;Pwd=mypass;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;")

Thanks!

Joshua Spiewak

unread,
Jul 29, 2016, 11:06:23 AM7/29/16
to shinyapps.io Users
Interesting that Azure requires that while AWS does not.

From the FreeTDS documentation, they don't really recommend using 8.0, even though it will alias to 7.1, as it might come into use in the future. I have also verified that 7.2 works and that 7.3 and 7.4 do not.

Manohar Reddy

unread,
Aug 18, 2016, 10:45:11 AM8/18/16
to shinyapps.io Users
Hi,
 
   I'm trying to connect the MS Sql server from R studio using  freeDTS drivers but while connecting i have encountered error for this PFA,i have changed the freeTDS versions also though noluck.i'm suspecting that i didn't configured freeTDS drivers properly.Can anyone help out me to how to register freeTDS drivers with RODBC and how to configure it on Windows 8.

Thanks in Advance..

Manu.
Freetds driver error message.PNG

Joshua Spiewak

unread,
Aug 18, 2016, 11:04:39 AM8/18/16
to shinyapps.io Users
Are you having problems on shinyapps.io, or locally?
This list is specifically for shinyapps.io, which is hosted on Linux servers.
If you are having general Shiny questions, you can post to the shiny-discuss group.

But it reads as though you are having just a straight issue with R, RODBC, freeTDS and MS SQL locally on a Windows 8 host. I would suggest seeing if you can find a way to verify your installation and configuration of freeTDS outside of R first. When I was trying to figure out connecting to Azure, I found the freeTDS user guide handy, specifically the section on DSN-less connections, which was applicable to shinyapps.io, but since you are local, you should be able to fully define a DSN to your data source.

Hope that helps get you headed in the right direction. I don't have Windows myself, so if you are still having difficulty and have verified the freeTDS setup outside of R, I would suggest a follow question on a general R list.

Cheers!

Manohar Reddy

unread,
Aug 20, 2016, 5:15:39 AM8/20/16
to shinyapps.io Users
Hi Joshua,

 Actually my requirement is I need to develop the web application/report then I need to host it on shinyapps.io ,so for that I have developed a report and deployed into shinyapps.io,after deployed into that whenever I ever I click on URL I got a error message like “first argument is not an open RODBC channel” based on this error message did searched in a google and found that we need to use freeTDS driver instead of RODBC,so I was trying to connect the freeTDS but no luck ,can you please help me how to install and how to configure freeTDS on windows 8.

  Thanks,

Manohar Reddy

unread,
Aug 23, 2016, 11:45:49 PM8/23/16
to shinyapps.io Users
I’m eagerly waiting for someone reply ,can anyone  help out me on same. Thanks in advance !!! 

Joshua Spiewak

unread,
Aug 29, 2016, 11:54:12 AM8/29/16
to shinyapps.io Users
You need both RODBC and freeTDS.

I have documented in this thread how to use RODBC and freeTDS on shinyapps.io.
I don't run Windows myself and cannot help you with that part.

Alistair King

unread,
Oct 9, 2016, 8:20:22 AM10/9/16
to shinyapps.io Users
Hi, 

I'm, also trying to connect via shinyapps.io to ms SQL on Azure and AWS but both are failing.  It says that FreeTDS is not available - has there been a support change on ShinyApps.io to not provide FreeTDS?

I get the following error message when deploying:

Preparing to deploy application...DONE
Uploading bundle for application: 129078...
Error: Unable to retrieve package records for the following packages:
- "FreeTDS"

Any advice would be appreciated - I've tried all the solutions suggested in this thread.

Regards

Alistair

Tareef Kawaf

unread,
Oct 10, 2016, 8:06:35 AM10/10/16
to Alistair King, shinyapps.io Users
I am not 100% sure, but Josh's note seems to indicate that it is freeTDS and not FreeTDS.  could you try the former and see if it solves the problem?

--
You received this message because you are subscribed to the Google Groups "shinyapps.io Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-users+unsubscribe@googlegroups.com.
To post to this group, send email to shinyapps-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/24b439e5-5e4c-40cd-adfa-8adf124e77fe%40googlegroups.com.

Joshua Spiewak

unread,
Oct 11, 2016, 9:17:47 AM10/11/16
to shinyapps.io Users, ali.k...@googlemail.com
freeTDS is a system package that is installed and available.
RODBC is an R package.


On Monday, October 10, 2016 at 8:06:35 AM UTC-4, Tareef Kawaf wrote:
I am not 100% sure, but Josh's note seems to indicate that it is freeTDS and not FreeTDS.  could you try the former and see if it solves the problem?
Message has been deleted

Byron Rogers

unread,
Jul 7, 2017, 7:14:54 PM7/7/17
to shinyapps.io Users
I have had a similar issue as above, but after trying all of them I am none the wiser. The ShinyApp works on my local machine fine but when I deploy to shinyapps.io I get the following error in the logs.

2017-07-07T22:55:52.371239+00:00 shinyapps[194788]: 
2017-07-07T22:55:52.371240+00:00 shinyapps[194788]: Listening on http://127.0.0.1:44457
2017-07-07T22:56:00.999573+00:00 shinyapps[194788]: Warning in odbcDriverConnect(connection_string) :
2017-07-07T22:56:00.999689+00:00 shinyapps[194788]:   [RODBC] ERROR: state 01000, code 20013, message [unixODBC][FreeTDS][SQL Server]Unknown host machine name.
2017-07-07T22:56:00.833648+00:00 shinyapps[194788]: Guessing layer_points()
2017-07-07T22:56:00.999687+00:00 shinyapps[194788]: Warning in odbcDriverConnect(connection_string) :
2017-07-07T22:56:00.999576+00:00 shinyapps[194788]:   [RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
2017-07-07T22:56:00.999943+00:00 shinyapps[194788]: Warning in odbcDriverConnect(connection_string) :
2017-07-07T22:56:01.024894+00:00 shinyapps[194788]: Warning in odbcDriverConnect(connection_string) :
2017-07-07T22:56:01.004891+00:00 shinyapps[194788]:     78: getData
2017-07-07T22:56:01.004894+00:00 shinyapps[194788]:      8: tryCatch
2017-07-07T22:56:01.025146+00:00 shinyapps[194788]:   ODBC connection failed
2017-07-07T22:56:01.004889+00:00 shinyapps[194788]: Stack trace (innermost first):
2017-07-07T22:56:01.004892+00:00 shinyapps[194788]:     11: doTryCatch
2017-07-07T22:56:01.024798+00:00 shinyapps[194788]: Warning in odbcDriverConnect(connection_string) :
2017-07-07T22:56:01.004890+00:00 shinyapps[194788]:     79: sqlQuery
2017-07-07T22:56:01.004895+00:00 shinyapps[194788]:      5: eval
2017-07-07T22:56:01.004896+00:00 shinyapps[194788]:      3: eval
2017-07-07T22:56:01.004896+00:00 shinyapps[194788]:      2: eval.parent
2017-07-07T22:56:01.004892+00:00 shinyapps[194788]:     12: fn
2017-07-07T22:56:01.004897+00:00 shinyapps[194788]:      1: local
2017-07-07T22:56:01.050250+00:00 shinyapps[194788]: Stack trace (innermost first):
2017-07-07T22:56:00.999945+00:00 shinyapps[194788]:   ODBC connection failed
2017-07-07T22:56:01.004895+00:00 shinyapps[194788]:      6: eval
2017-07-07T22:56:01.025798+00:00 shinyapps[194788]: Warning: Error in sqlQuery: first argument is not an open RODBC channel
2017-07-07T22:56:01.004892+00:00 shinyapps[194788]:     13: runApp
2017-07-07T22:56:01.004895+00:00 shinyapps[194788]:      4: eval
2017-07-07T22:56:01.025145+00:00 shinyapps[194788]: Warning in odbcDriverConnect(connection_string) :
2017-07-07T22:56:01.004893+00:00 shinyapps[194788]:      9: tryCatchList
2017-07-07T22:56:01.024895+00:00 shinyapps[194788]:   [RODBC] ERROR: state 01000, code 20013, message [unixODBC][FreeTDS][SQL Server]Unknown host machine name.
2017-07-07T22:56:01.000777+00:00 shinyapps[194788]: Warning: Error in sqlQuery: first argument is not an open RODBC channel
2017-07-07T22:56:01.004891+00:00 shinyapps[194788]:     77: observeEventHandler [/srv/connect/apps/PerformanceShiny/server.R#42]
2017-07-07T22:56:01.004894+00:00 shinyapps[194788]:      7: connect$retry
2017-07-07T22:56:01.004893+00:00 shinyapps[194788]:     10: tryCatchOne
2017-07-07T22:56:01.024799+00:00 shinyapps[194788]:   [RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
2017-07-07T22:56:01.050253+00:00 shinyapps[194788]:     77: observeEventHandler [/srv/connect/apps/PerformanceShiny/server.R#70]
2017-07-07T22:56:01.050256+00:00 shinyapps[194788]:      8: tryCatch
2017-07-07T22:56:01.050254+00:00 shinyapps[194788]:     13: runApp
2017-07-07T22:56:01.050256+00:00 shinyapps[194788]:      7: connect$retry
2017-07-07T22:56:01.050257+00:00 shinyapps[194788]:      6: eval
2017-07-07T22:56:01.050257+00:00 shinyapps[194788]:      5: eval
2017-07-07T22:56:01.050254+00:00 shinyapps[194788]:     11: doTryCatch
2017-07-07T22:56:01.050258+00:00 shinyapps[194788]:      4: eval
2017-07-07T22:56:01.050255+00:00 shinyapps[194788]:      9: tryCatchList
2017-07-07T22:56:01.050255+00:00 shinyapps[194788]:     10: tryCatchOne
2017-07-07T22:56:01.050258+00:00 shinyapps[194788]:      3: eval
2017-07-07T22:56:01.050252+00:00 shinyapps[194788]:     79: sqlQuery
2017-07-07T22:56:01.050254+00:00 shinyapps[194788]:     12: fn
2017-07-07T22:56:01.050253+00:00 shinyapps[194788]:     78: getData
2017-07-07T22:56:01.050258+00:00 shinyapps[194788]:      2: eval.parent
2017-07-07T22:56:01.050259+00:00 shinyapps[194788]:      1: local



In SQL Studio I queried the version of Server that I am running and it returned "Microsoft SQL Azure (RMT) - 12.0.2000.8 June 11 2017 11:55:10"

I wasnt sure if that had effect on the TDS setting. I have entered all the advised Firewall settings into Azure Portal associated with the SQL Server.

For the TDS setting I have tried version 7.0, 7.1, 7.4 and 8.0

The code I am using to switch between a local instance and a shinyapp instance is:
if (Sys.getenv('SHINY_PORT') == "") {

  SQL_Server_connection_string <- 'Driver={ODBC Driver 13 for SQL Server}; Server=tcp:xxxxxxx.database.windows.net,1433;Database=xxxxxxx;Uid=xxxxxx;Pwd=xxxxxx;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;'

} else {

  SQL_Server_connection_string <- 'Driver=FreeTDS;TDS_Version=7.0; Server=tcp:xxxxxxx.database.windows.net,1433;Database=xxxxxxx;Uid=xxxxxx;Pwd=xxxxxx;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;'

}

Any idea what is going wrong?

Kevin Little

unread,
Jul 8, 2017, 12:19:54 AM7/8/17
to shinyapps.io Users
In your connection string, the separators are supposed to be semi-colon, https://msdn.microsoft.com/en-us/library/ms722656(v=vs.85).aspx?  check the punctuation between the server value and the port value...   e,g, we have a shiny app on shinyapps.io successfully communicating with a SQL db and our connect string looks like:  
dbcon_dev_shiny <- odbcDriverConnect("Driver=FreeTDS;TDS_Version=7.4;Server=xx.xx.xxx.xxx;Port=1433;Database=yyyyyyyy;Uid=zzzzz;Pwd=aaaaaaaaa;")   

I can't explain why your string would run locally, however, if this is in fact the issue....

Joshua Spiewak

unread,
Jul 10, 2017, 8:54:03 AM7/10/17
to shinyapps.io Users
Is the database you are trying to access allowing connections from the shinyapps.io IP addresses?

Manohar Reddy

unread,
Jul 10, 2017, 11:33:19 AM7/10/17
to Joshua Spiewak, shinyapps.io Users
 All,

   This is what i got solution from shinyapps group and i had made a successful connection to ms sql server.

> Frediano will correct me if I'm wrong, but I don't think there is a
> binary distribution file
> you can just download and install.
> You need to grab the source code, get either MSVC or MinGW compiler and compile
> the software yourself.
>

About installer you are right, about binaries I would download
https://ci.appveyor.com/project/FreeTDS/freetds/build/643/job/ct9rf92mw0vcyv3l/artifacts
or
https://ci.appveyor.com/project/FreeTDS/freetds/build/643/job/h5h5h2oekntgaqg3/artifacts
(32 or 64 bit) and register tdsodbc.dll with regsvr32 utility.
You should download and install OpenSSL from
https://slproweb.com/products/Win32OpenSSL.html before.

In win32 directory there is an old source for a NSIS installer but
probably would require some additional library (MSVC/OpenSSL).

--
You received this message because you are subscribed to the Google Groups "shinyapps.io Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-users+unsubscribe@googlegroups.com.
To post to this group, send email to shinyapps-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--


Manu.
Reply all
Reply to author
Forward
0 new messages