Reputation: 251
I'm trying to make a connection to PostgreSQL database in R.
I'm writing this
drv <- dbDriver("PostgreSQL")
But in result i have an error:
Error: Couldn't find driver PostgreSQL. Looked in:
* global namespace
* in package called PostgreSQL
* in package called RPostgreSQL
What am I doing wrong?
Upvotes: 2
Views: 5484
Reputation: 387
I had a similar issue when writing a package, and inspired by the above answers I found putting:
#' @import RPostgreSQL
at the top of any function which used DBI::dbDriver("PostgreSQL")
fixed the problem.
Upvotes: 0
Reputation: 368
Had the same problem on debian, following helped:
apt-get -y install r-cran-rpostgresql
Upvotes: 0
Reputation: 91
Package Issue
drv <- DBI::dbDriver("PostgreSQL")
When you use this code you must include the library that uses the driver package so it wont give you an error please use this code and i am sure it will work
library("RPostgreSQL")
drv <- DBI::dbDriver("PostgreSQL")
and that will solve your issue
Upvotes: 1
Reputation: 91
drv <- DBI::dbDriver("PostgreSQL")
gives me the same error but loading RPostgreSQL
library("RPostgreSQL")
before making the connection solves it.
Upvotes: 8