RODBC error with shiny apps

469 views
Skip to first unread message

Philip Moy

unread,
Oct 23, 2015, 1:07:11 PM10/23/15
to ShinyApps Users

I was able to deploy my app with shinyapps but I keep getting error:

ERROR: first argument is not an open RODBC channel

My app contains 3 files:

ui.R
server.R
plots.R

plots.R:

library(RODBC)
library(ggplot2)

queryfunction <- function(channel) {
    myconn <- odbcConnect(dsn = "SQLServer")   
    query = "my query"
   df <- sqlQuery(channel = myconn, query = query)
   odbcClose(myconn)
   return(df)
    }

plotfunction <- function(channel) {
  a <- ggplot(queryfunction(channel), aes(x = Month, y = Volume)) + 
    geom_bar(stat='identity')
    return(a)
}

server.R:

library(shiny)
source('plots.R')
shinyServer(function(input, output,session) {

  #general volume, value, and table plots
  output$plot1 <- renderPlot({plotfunction(channel)})
})

This works perfectly fine on my own computer, but somehow on the server it doesn't. Does anyone know what the issue is?

Tareef Kawaf

unread,
Oct 23, 2015, 1:50:55 PM10/23/15
to Philip Moy, ShinyApps Users
Yes, unfortunately we don't have SQLServer drivers installed on the server so it isn't able to connect to your database.  
We currently only support open source databases on shinyapps.io, but we are watching to see if we get a lot more requests for proprietary databases.

--
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/45234b6a-e0d1-4d58-9ea8-2f67e4ecaf26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kai Ross

unread,
Oct 23, 2015, 2:14:51 PM10/23/15
to ShinyApps Users
I was trying to figure out the same issue, but for a Microsoft Access Database (.mdb).  So I would say count me as  +1 for requesting proprietary databases.

Tareef Kawaf

unread,
Oct 23, 2015, 3:06:03 PM10/23/15
to Kai Ross, ShinyApps Users
Hi Kai, 
Andy corrected me (while on vacation) and let me know that you can make this work by using the FreeTDS driver.  I am not an expert on this, but if you change your code to something like this:

odbcDriverConnect("driver=FreeTDS;Server=hostname;database=dbname;uid=username;pwd=password")

We don't have any DSNs configured, but you can see tips for how to do this here:


-Tareef


On Fri, Oct 23, 2015 at 2:14 PM, Kai Ross <mailk...@gmail.com> wrote:
I was trying to figure out the same issue, but for a Microsoft Access Database (.mdb).  So I would say count me as  +1 for requesting proprietary databases.

--
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.

Philip Moy

unread,
Oct 23, 2015, 3:13:58 PM10/23/15
to ShinyApps Users, mailk...@gmail.com
Tareef, will this work if I am using Windows?

Tareef Kawaf

unread,
Oct 23, 2015, 3:52:07 PM10/23/15
to Philip Moy, ShinyApps Users, mailk...@gmail.com
Unfortunately I don't think it will, I am not an expert, but I think you essentially have to have a different connection string based on whether this is running on Windows or on Ubuntu (Linux)

Kai Ross

unread,
Oct 26, 2015, 1:17:36 PM10/26/15
to ShinyApps Users, mailk...@gmail.com
Hi Tareef,
Thank you for getting back to me on this. Unfortunately I still haven't been able to get it to work.

I changed my code to:
conn=odbcDriverConnect("Driver=FreeTDS;Server=##.###.##.##;Database=/srv/connect/apps/My_app/My_data.mdb;Uid=;Pwd=;")

But get the error:
[RODBC] ERROR: state 08001, code 0, message [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
When deployed to shinyapps.io

The link you provided shoes how they configured the odbcinst.ini file, but I don't think I have access to those directories by uploading a shiny app.

If you have any thoughts on what I'm doing incorrectly, or what other files I'd need to upload with my app to make things work, I'd be happy to hear them.
Thanks for your time,
-Kai

Andy Kipp

unread,
Oct 26, 2015, 1:46:57 PM10/26/15
to Kai Ross, ShinyApps Users
Kai,

Unfortunately, MS Access (MDB files) are not the same as MS SQL Server, and are not supported on shinyapps.io.

-Andy

Christopher Dailey

unread,
Jan 27, 2016, 11:13:30 PM1/27/16
to ShinyApps Users
I'm also interested in reading .accdb files from shinyapps.  The group I'm working with saves everything in an Access 2007 database and I'd like them to be able to upload the database file so I can run queries against it.  Having those drivers loaded onto the server would make it all work.  +1.

Andy Kipp

unread,
Jan 29, 2016, 10:25:28 AM1/29/16
to Christopher Dailey, ShinyApps Users
The problem here isn't really the fact that we don't load the drivers, its the fact that no driver exists that can read MSAccess files on any platform besides Windows (Shinyapp.io runs on Linux). 



--
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.

Christopher Dailey

unread,
Jan 29, 2016, 8:24:03 PM1/29/16
to ShinyApps Users, christoph...@gmail.com
Man, that's a bummer :/
Reply all
Reply to author
Forward
0 new messages