Skip to content
Prev 1476 / 1559 Next

DBI preferred syntax

I reported earlier in this thread that this works:

Type 'q()' to quit R.
 > require("RPostgreSQL")
Loading required package: RPostgreSQL
Loading required package: DBI
 > require("DBI")
 > z <-dbConnect(RPostgreSQL::PostgreSQL(), dbname="test")   #works

but there are some circumstance I have not isolated where if fails with 
the same problem as this (which fails reliably):

Type 'q()' to quit R.
 > requireNamespace("RPostgreSQL")
Loading required namespace: RPostgreSQL
 > require("DBI")
Loading required package: DBI
 > z <- dbConnect(RPostgreSQL::PostgreSQL(), "test")
Error in postgresqlNewConnection(drv, ...) :
   RS-DBI driver: (could not connect test at local on dbname "test"
)

For some reason, done this way it does not find my setting of 
environment variable PGHOST, which is not localhost, and picks up test 
as my user name, which is not correct.

(As before
 >> R version 3.1.1 (2014-07-10) -- "Sock it to Me"
 >> DBI         "DBI"         "0.3.1"
 >> RPostgreSQL "RPostgreSQL" "0.4"
)

Paul
On 10/11/2014 01:30 PM, Hadley Wickham wrote: