Search code examples
rr-packagerpostgresql

using dbDriver("PostgreSQL") in R package


I'm trying to put together a small package that makes use of R's PostgreSQL package. I understand that the way to use functionality from other packages is not to use library() but to import only single functions using namespacing. I'm having a hard time making this work, however.

Here's the Imports section of my DESCRIPTION file:

Imports: DBI,
RPostgreSQL

When I call

DBI::dbDriver("PostgreSQL")

in a function in my package I get

Error: Couldn't find driver PostgreSQL. Looked in:
* global namespace
* in package called PostgreSQL
* in package called RPostgreSQL

What am I missing?


Solution

  • Using

    RPostgreSQL::PostgreSQL()
    

    instead of

    DBI::dbDriver("PostgreSQL")
    

    works.