[R] Problem connecting to database via RPostgreSQL/RS-DBI: "could not connect" error

andrewH ahoerner at rprogress.org
Sat Feb 1 04:40:27 CET 2014


In the description section of the RPostgreSQL package documentation, it
states:

"In order to build and install this package from source, PostgreSQL itself
must be present your system to provide PostgreSQL functionality via its
libraries and header files. . . . On Microsoft Windows system the attached
libpq library source will be used."

I am not sure what "attached" means in this setting. 

After successfully running:
  install.packages('RPostgreSQL')

When I tried to run:
   require('RPostgreSQL')
   drv <- dbDriver("PostgreSQL", fetch.default.rec=10000)
   con <- dbConnect(drv, dbname="postgres")

I get the error message:
  Error in postgresqlNewConnection(drv, ...) : 
  RS-DBI driver: (could not connect Administrator at local on dbname
"postgres")

I am guessing that this error is because PostgreSQL either does not exist or
has been improperly installed.

Since RPostgreSQL is supposed to work with the particular version of
PostgreSQL that comes with it in libpq, I assume that either
install.packages('RPostgreSQL') does this installation or I have to do it. 
I have not done it, because I can not find "attached libpq library". There
is no file or directory called either "libpq" or "PostgreSQL" in my \Program
Files\ directory, my \R-3.0.2 directory, my \R-3.0.2 \library directory, or
my R-3.0.2\library\RPostgreSQL directory,  nor is such a file or folder in
my working directory. There is no library called libpq on CRAN. There is no
discussion that I could find of how to install it, where it comes from, or
where installation puts it in either the package documentation or on the
Google site for the package, http://code.google.com/p/rpostgresql/   At that
site under the Source tab I did find some files at RPostgreSQL/src/libpq,
but no information on what to do with them.

I tried:
require('libpq')

and got:
Warning message:  In library(package, lib.loc = lib.loc, character.only =
TRUE, logical.return = TRUE,  :
  there is no package called ‘libpg’

I though maybe I was misunderstanding what or where libpq is, and that I
should be going to the PostgreSQL site and folowing their installation
instructions without reference to R. But I have carefully gone over the
documentation for dbDriver and dbConnect several times, and neither one
gives me any way (except a name or an IP address for a remote server) to
tell R where the PostgreSQL directory, program, or file are located. That
seems to imply that the local database RPostgreSQL connects to must be in a
location where R puts it. So I am missing something, but I do not know what. 

I am running R 3.0.2 through RStudio on a Windows XP 32-bit machine.

Any help anyone could offer would be greatly 

Warmest regards, andrewH




--
View this message in context: http://r.789695.n4.nabble.com/Problem-connecting-to-database-via-RPostgreSQL-RS-DBI-could-not-connect-error-tp4684534.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list