Connecting PostgreSQL with R

南楼画角 提交于 2019-12-04 05:55:03

问题


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?


回答1:


drv <- DBI::dbDriver("PostgreSQL")

gives me the same error but loading RPostgreSQL

library("RPostgreSQL") 

before making the connection solves it.




回答2:


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



来源:https://stackoverflow.com/questions/29755483/connecting-postgresql-with-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!