Shiny + Database

288 views
Skip to first unread message

THIAM HUAT Tan

unread,
Mar 2, 2015, 8:43:03 PM3/2/15
to shiny-...@googlegroups.com
I need to link Shiny with the Database (SQL Server 2008), and extract some data from there, do some data analysis, and present the result to Shiny as a web application, is that possible?
What are the settings required on the SQL Server 2008 side, to open it to different users Authentication via internet?

are there some examples on this?

Sean Davis

unread,
Mar 2, 2015, 11:37:23 PM3/2/15
to shiny-...@googlegroups.com


On Monday, March 2, 2015 at 8:43:03 PM UTC-5, THIAM HUAT Tan wrote:
I need to link Shiny with the Database (SQL Server 2008), and extract some data from there, do some data analysis, and present the result to Shiny as a web application, is that possible?
What are the settings required on the SQL Server 2008 side, to open it to different users Authentication via internet?

Your shiny server.R file will do the work of connecting to the SQL server.  As long as you can connect to SQL server from R (you should make sure that you can), you can use the same code in the shiny app to do the connection and queries.

THIAM HUAT Tan

unread,
Mar 3, 2015, 2:11:49 AM3/3/15
to shiny-...@googlegroups.com
on the local host, there is no issue, I can connect and get the string from the database.
but when deploy in internet, there is connectivity issue.

I have tried with MySQL which I allow for remote access over internet with "grant all privileges on *.*", but it still faces the same issue. Can you check what is the error on your server for 
https://pepperl-fuchs.shinyapps.io/MySQL/

printscreens here...http://imgur.com/T8m4P3Y 
localhost 127.0.0.1 works.. but in shinyapps.io failed.

# Retrieve_MySQL.R 
library(RMySQL) 
mydb = dbConnect(MySQL(), user='test', password='PASSWORD', dbname="bookstore") 

output = fetch(dbSendQuery(mydb, "SELECT book_id, title, Isbn, description FROM books WHERE genre = 'tutorials';"))

# server.R

title <- source('Retrieve_MySQL.R')

shinyServer( 
function(input, output) { 
output$text1 <- renderText({ 
paste("Title is", title[[1]]$title) 
}) 


)

Andy Kipp

unread,
Mar 3, 2015, 9:44:21 AM3/3/15
to THIAM HUAT Tan, shiny-discuss
Hi,

Is the database you're are accessing accessible to the shinyapps.io servers? It looks like you are connecting to a database that is hosted locally on your computer (localhost), which will not work.

-Andy

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/ed8cbe44-3fa1-4b97-b3a8-649551e30ae8%40googlegroups.com.

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

THIAM HUAT Tan

unread,
Mar 3, 2015, 8:33:37 PM3/3/15
to shiny-...@googlegroups.com, tanthi...@gmail.com
Can I check HOW do I make my database accessible to the shinyapps.io servers?
Could you list down the steps required, saying I am using the MySQL database?
thank you.

Andy Kipp

unread,
Mar 4, 2015, 9:42:24 AM3/4/15
to THIAM HUAT Tan, shiny-discuss
The answer to that question is probably outside the scope for this mailing list as it depends on your local network. Could you reach out to your network administrator for help?

ALKA

unread,
Jun 6, 2018, 11:02:19 AM6/6/18
to Shiny - Web Framework for R
Hi, 

Did you ever find solution to this problem?

I am currently in the same situation using a MySql database that I want to connect to shiny.


On Monday, March 2, 2015 at 8:43:03 PM UTC-5, THIAM HUAT Tan wrote:
Reply all
Reply to author
Forward
0 new messages