本文介绍了如何制作可重复的数据库连接示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我需要对可以查询数据库时出现的错误做出可重复的示例。有时这些错误不能使用内置的数据集进行复制。

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")

但它给我一个错误

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?

推荐答案

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)

这篇关于如何制作可重复的数据库连接示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 15:07