0

I want to use the megaptera::dbPars() function as per the megaptera vignette, however I keep receiving errors when executing the function. My PostgreSQL can be accessed through pgAdmin 4 as well as through the command line and works fine. The functions included in the RpostgresSQL package work fine, and I have DBI installed. What can I do to get this code to work?

> 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
Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

The CRAN version of the package (v1.0-0) was last updated 2014-11-13 but the package's maintainer has been active on GitHub. The Git version 1.0-52 was last updated 2016-10-21. After updating, the code works as expected.

> 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