database_config.Rmd
library(tidydb2)
# usethis::edit_file("~/.db.yml")
edit_db_config()
#> Warning in normalizePath("~/.db.yml"): path[1]="/home/runner/.db.yml": No such
#> file or directory
#> ☐ Edit /home/runner/.db.yml.
按照如下格式填写,可以填写多个配置。
在不指定name
或dbname
的情况下,默认读取第一个。
kong-nas:
host: kong-nas
user: CUG
pwd: passwd
port: 3306
dbname:
- ChinaMet
remote-nas:
host: xxxhydro.top
user: CUG
pwd: pwd
port: 2306
dbname:
- ChinaMet
default: kong-nas
这里有改进空间
# source('scripts/main_pkgs.R')
config = yaml::read_yaml("~/.db.yml")
dbinfo = get_dbInfo() # see which db to read
con_mysql = open_mysql()
con_mariadb = open_mariadb(1, dbinfo)