andrewH
2014-Feb-01 03:40 UTC
[R] Problem connecting to database via RPostgreSQL/RS-DBI: "could not connect" error
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.
Christian Oswald
2014-Feb-03 13:31 UTC
[R] Problem connecting to database via RPostgreSQL/RS-DBI: "could not connect" error
Hello, what's your operating system? Windows? Perhaps you don't have an account administrator in the postgresql. libpg is not a R-library it's system dependent. (ubuntu "apt-get install libpg-dev") Christian Am 31.01.2014 22:40, schrieb andrewH:> 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. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hadley Wickham
2014-Feb-03 15:24 UTC
[R] Problem connecting to database via RPostgreSQL/RS-DBI: "could not connect" error
On Fri, Jan 31, 2014 at 9:40 PM, andrewH <ahoerner at rprogress.org> wrote:> > 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.Or you're not running a postgres db on your local machine with that accepts a connection with username Administrator and no password? I doubt that's the error you would see if RPostgreSQL hadn't found libpq. Hadley -- http://had.co.nz/