[R-sig-DB] DBI preferred syntax

Hadley Wickham h@w|ckh@m @end|ng |rom gm@||@com
Wed Oct 15 17:46:30 CEST 2014


On Tue, Oct 14, 2014 at 5:22 PM, Paul Gilbert <pgilbert902 using gmail.com> wrote:
> 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 using 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.

I suspect this is because RPostgreSQL needs some tweaks to work when
it's not attached - it's possible it's using .onAttach instead of
.onLoad for initialisation.

Hadley

-- 
http://had.co.nz/




More information about the R-sig-DB mailing list