从Hadley对这个
pull request的回应(2014年2月,要求调整代码以允许阅读my.cnf)和
documentation by Hadley(他建议使用my.cnf并且你应该传递NULL值)看来,传递NULL是期望的意图.
如果这很麻烦,请考虑使用以下内容在.Rprofile中创建一个函数:
src_mysql_from_cnf
dir="~/.my.cnf",
host=NULL,
user=NULL,
password=NULL,
...) {
if(!(file.exists(dir)))
stop(sprintf("No such file '%s'",dir))
dplyr::src_mysql(
dbname,
default.file=path.expand(dir),
# explicitly passing null unless otherwise specified.
host=host,
user=user,
password=password,
...)
}
那么你可以
test_db