Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to PostgreSQL using R (in windows)

Tags:

r

postgresql

I have this R code and i want to connect to a postgres db using the conf file:

con <- dbConnect(PostgreSQL(), groups='epl')

The postgresql.conf file contains:

#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------

# Add settings for extensions here
[epl]
host='localhost'
port = 5432
dbname='rlearning'
user='user'
password='pass'

When I run the R code, i get this error:

Error in postgresqlNewConnection(drv, ...) : 
  unused argument(s) (groups = "epl")
like image 443
Robin Winton Avatar asked Feb 17 '23 08:02

Robin Winton


1 Answers

If everything else fails, you can try reading the documentation and following the examples. For help(dbConnect), you find

# create an PostgreSQL instance and create one connection.
drv <- dbDriver("PostgreSQL")

# open the connection using user, passsword, etc., as
con <- dbConnect(drv, dbname = "postgres")

and this is where you add additional user, password, host, arguments.

It will also show you that there is no argument groups explaining the error you get.

like image 153
Dirk Eddelbuettel Avatar answered Feb 20 '23 00:02

Dirk Eddelbuettel