How to connect shinyapps.io with the shiny app which is connected to local database using SQL server

94 views
Skip to first unread message

Venkata Sridhar P

unread,
Jun 23, 2018, 1:16:20 PM6/23/18
to shinyapps.io Users

I have made a sample shiny app that gets connected with the SQL Server running on my local host. I have created a free account in shinyapps.io and when I tried to deploy to it, I am getting the error "failed to load from server"

library(shiny)
library(shinydashboard)
library(RMySQL)
library(lubridate)
library(DBI)


con_iris <- DBI::dbConnect(
  drv = RMySQL::MySQL(),
  dbname = "iris_db",
  host = "localhost",
  username = "XXXX",
  password = "XXXXXX"
)



ui<-shinyUI(fluidPage(
  #fluid page for dynamically adapting to screens of different resolutions.
  titlePanel("Iris Dataset"),
  sidebarLayout(
    sidebarPanel(
      selectInput("select", label = h5("select species"),choices = c("setosa"=1, "Vericolor"=2, "virginica"=3), 
                  selected = 1)
                ),
    mainPanel(
      textOutput("data")
    )
  )
))

server<-shinyServer(function(input, output) {

  #referring output distPlot in ui.r as output$distPlot
  output$data <- renderText({
      query<-paste0("select * from iris where Species= '", input$select , "'", sep='')
      species<-dbGetQuery(con_iris, query)
      })
})

shinyApp(ui=ui,server=server)

Can anyone help me like what are all the procedural changes that needs to be done in the code/shinyapps.io account....to deploy the shiny app and fetch data from the sql server which is hosted locally in my machine...because i couldn't any proper steps to connect with my local server...reallly need help in this guys...!!!

Manohar Reddy

unread,
Jun 23, 2018, 10:41:33 PM6/23/18
to Venkata Sridhar P, shinyapps.io Users
Sridhar,you have to use freetds package instead of Rmysql.

--
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-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/cacc6d6a-6400-4d6a-8063-e132b4221fdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Venkata Sridhar P

unread,
Jun 23, 2018, 11:19:15 PM6/23/18
to shinyapps.io Users
Can you please tell me steps required like how to use it and make the changes...sry for it i am a newbie to shiny....and i t will be greatful if i could get any help on this
db_Read.R

Joshua Spiewak

unread,
Jun 25, 2018, 9:43:28 AM6/25/18
to shinyapps.io Users
Additionally, you will need to change "localhost" to a public name for your database, or it's public IP address, as there is no database running on shinyapps.io itself for you to connect to.
See the documentation onĀ Accessing Databases with odbc
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.
Reply all
Reply to author
Forward
0 new messages