如何制作可重现的数据库连接示例?

时间:2016-08-03 20:03:10

标签: r dplyr

我不时需要制作有关查询数据库时出现的错误的可重现的示例;有时这些错误无法使用内置数据集重现。

是否有可用于制作可重复示例的公开数据库列表? 我知道他的一个

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

但它给了我一个错误

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

我在臭名昭着的问题How to make a great R reproducible example?

中找不到任何关于这种特定情况的提法

1 个答案:

答案 0 :(得分:1)

来自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)