Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a reproducible example of a database connection?

Tags:

r

dplyr

From time to time I need to make reproducible examples about errors I get when querying a database; sometimes these errors cannot be reproduced using the built-in datasets.

Is there any list of publicly available databases that we can use to make reproducible examples? I knew about his one

 src_mysql(dbname = "dplyr", 
                 host = "dplyr.csrrinzqubik.us-east-1.rds.amazonaws.com", 
                 port = 3306, 
                 user = "dplyr",
                 password = "dplyr")

But it gives me an error

Error in .local(drv, ...) : 
  Failed to connect to database: Error: Unknown MySQL Server Host 'dplyr.csrrinzqubik.us-east-1.rds.amazonaws.com' (8)

I didn't find any reference to this specific circumstance in the notorious question How to make a great R reproducible example?

like image 914
Dambo Avatar asked Aug 03 '16 20:08

Dambo


1 Answers

From http://shiny.rstudio.com/articles/

library(dplyr)
my_db <- src_mysql(
  dbname = "shinydemo",
  host = "shiny-demo.csa7qlmguqrf.us-east-1.rds.amazonaws.com",
  user = "guest",
  password = "guest"
)
# get the first 5 rows:
my_db %>% tbl("City") %>% head(5)
like image 178
Dambo Avatar answered Sep 28 '22 18:09

Dambo