[R] postgres/R access problems

Brendan Murray brendan at peblnz.com
Sun Feb 9 23:37:03 CET 2003


On Mon, 2003-02-10 at 11:06, ripley at stats.ox.ac.uk wrote:
> I was asking about which R *package* and version: R itself does not
> interface to any DBMS, but there are several ways to interface to PgSQL
> and they are *packages* like RPgSQL, which has different versions in
> different repositories (although AFAIK none are current on CRAN).
> (There is also a dbi.something package.)

Ah. Now that my brain is in gear.....  the db.connect in question looks
to be from RPgSQL. I suspect it came from sourceforge. Interesting that
the maintainer has declared it obsolete - I didn't realise that. More
complications

Package: RPgSQL
Version: 1.0-0
Date: Wed Jun 20 15:18:04 EDT 2001
Title: PostgreSQL access
Author: Timothy H. Keitt <thk at users.sourceforge.net>
Maintainer: Timothy H. Keitt <thk at users.sourceforge.net>
Description: Provides methods for accessing data stored in PostgreSQL
             tables.
Depends: R (>= 1.2)
License: GPL (version 2 or higher; see LICENSE)
URL: http://rpgsql.sourceforge.net/
Built: R 1.5.1; i686-pc-linux-gnu; Fri Jul 5 16:50:14 NZST 2002

These are the loaded libraries from the script I was using to test.

library(DBI)
library(Rdbi)
library(RPgSQL)

I have since tried it without DBI and Rdbi and got exactly the same
error 

Error in db.connect(host = "praetorius", .... 

This is the whole script (passwords elided)

# mine.R
thingy <- function(){

#CLEANING UP AND LOADING THE NECESSARY R FUNCTIONS
rm(list=ls())

#library(DBI)
#library(Rdbi)
library(RPgSQL)

#SELECT THE HYBS TO BE NORMALISED
query <- paste("select usename from pg_user");

print(query);

db.connect(host="praetorius",dbname="testdb",
pass="XXXXXXX",user="brendan"); 
db.execute(query, clear=F);

things<- db.fetch.result();
print(things);

}
# end script

The 'select' works just fine if I use it in psql

> 
> That's the vital piece of information: db.connect is not a part of R per 
> se, and that seems to be where the problem is.

Oh yeah. That part I got to, and thats where my only-recent exposure to
R started me lost. I know unix backwards, but I'm an OS person, not an
app person. I know that when I use tcpdump to trace the transactions the
machines are talking together, and I can't see anything particularly
different between the transactions when it works and when it doesn't,
except that the one that works returns data. 

R is happy  enough when I get the data. I've just got this odd ball
problem where it seems to work fine on some boxes and not on others,
despite the fact that they should be damn near identical. The box that
works is the 'definitive' workstation in the lab and we rsync changes to
it out to the others, though that doesn't stop them getting slowly
different from each other as various people need specific
enhancements/software. 

\
> >




More information about the R-help mailing list