megaptera::dbPars() 不会与 PostgreSQL 连接
megaptera::dbPars() won't connect with PostgreSQL
我想按照 megaptera vignette 使用 megaptera::dbPars()
函数,但是在执行该函数时我一直收到错误消息。可以通过 pgAdmin 4 以及命令行访问我的 PostgreSQL,并且工作正常。 RpostgresSQL
包中包含的功能工作正常,我安装了 DBI
。我该怎么做才能使此代码正常工作?
> drv <- dbDriver("PostgreSQL")
> conn <- dbPars(dbname = "Cetacea",
host = "localhost", port = 5432,
user = "openpg", password = "new_user_password")
## Error in postgresqlNewConnection(drv, ...) :
## RS-DBI driver: (could not connect openpg@local on dbname "openpg"
## )
> con <- dbConnect(PostgreSQL(), dbname = "newdata",
host = "localhost", port = 5432,
user = "openpg", password = "new_user_password")
> dbExistsTable(con, "iris")
## [1] TRUE
> sessionInfo()
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows >= 8 x64 (build 9200)
## locale:
## [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
## other attached packages:
## [1] megaptera_1.0-0 ips_0.0-9 XML_3.98-1.5 ape_4.0
## [5] snowfall_1.84-6.1 snow_0.4-2 RPostgreSQL_0.4-1 DBI_0.5-1
包的 CRAN 版本 (v1.0-0) 最后更新于 2014 年 11 月 13 日,但包的维护者在 GitHub 上一直处于活动状态。 Git 版本 1.0-52 最后更新于 2016-10-21。更新后,代码按预期工作。
> library(devtools); install_github("heibl/megaptera")
> drv <- dbDriver("PostgreSQL")
> conn <- dbPars(dbname = "Cetacea",
host = "localhost", port = 5432,
user = "openpg", password = "new_user_password")
> show(conn)
## PostgreSQL connection parameters:
## host = localhost
## port = 5432
## dbname = cetacea
## user = openpg
## password = new_user_password
我想按照 megaptera vignette 使用 megaptera::dbPars()
函数,但是在执行该函数时我一直收到错误消息。可以通过 pgAdmin 4 以及命令行访问我的 PostgreSQL,并且工作正常。 RpostgresSQL
包中包含的功能工作正常,我安装了 DBI
。我该怎么做才能使此代码正常工作?
> drv <- dbDriver("PostgreSQL")
> conn <- dbPars(dbname = "Cetacea",
host = "localhost", port = 5432,
user = "openpg", password = "new_user_password")
## Error in postgresqlNewConnection(drv, ...) :
## RS-DBI driver: (could not connect openpg@local on dbname "openpg"
## )
> con <- dbConnect(PostgreSQL(), dbname = "newdata",
host = "localhost", port = 5432,
user = "openpg", password = "new_user_password")
> dbExistsTable(con, "iris")
## [1] TRUE
> sessionInfo()
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows >= 8 x64 (build 9200)
## locale:
## [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
## other attached packages:
## [1] megaptera_1.0-0 ips_0.0-9 XML_3.98-1.5 ape_4.0
## [5] snowfall_1.84-6.1 snow_0.4-2 RPostgreSQL_0.4-1 DBI_0.5-1
包的 CRAN 版本 (v1.0-0) 最后更新于 2014 年 11 月 13 日,但包的维护者在 GitHub 上一直处于活动状态。 Git 版本 1.0-52 最后更新于 2016-10-21。更新后,代码按预期工作。
> library(devtools); install_github("heibl/megaptera")
> drv <- dbDriver("PostgreSQL")
> conn <- dbPars(dbname = "Cetacea",
host = "localhost", port = 5432,
user = "openpg", password = "new_user_password")
> show(conn)
## PostgreSQL connection parameters:
## host = localhost
## port = 5432
## dbname = cetacea
## user = openpg
## password = new_user_password