Thanks a lot for your response Peter,

> I've not used these libraries, but one important question is are you
familiar
> with both R and python?

No, i'm beginer... but i need to learn this two technology this summer,
because this is the student job (geography/computer science student) :-]]

import rpy
rpy.set_default_mode(rpy.NO_
>
> CONVERSION)
> #your code here:
> rpy.r.library("Rdbi")
> rpy.r.library("RdbiPgSQL")
> rpy.r.dbConnect(rpy.r.PgSQL(),host="localhost", dbname="simpop",
> user="postgres", password="postgres")
> #If you want to go back to the default conversion,
> rpy.set_default_mode(rpy.BASIC_CONVERSION)
>

Connection is ok with this code, thanks a lot to help me !

Seb

On Thu, Jun 25, 2009 at 3:20 PM, Peter <rpy-l...@maubp.freeserve.co.uk>wrote:

> On Thu, Jun 25, 2009 at 2:08 PM, reyman<reyma...@gmail.com> wrote:
> > Hello guys,
> >
> > I have a big project for six month, i need a little help about technology
> > imbrication ...
> >
> > 1) Reflexion about System architecture
> >     > a) I want to make script in python which control/launch R, R access
> > data with library "rdbi" and "RdbiPgSQL". I need this to realize simple
> > statistics. Do you think it's better to access data in DB with R or with
> > python in this case ?
> >     > b) I want in near futur to create an another type of script wich
> > access data in DB with grass by R module "spgrass6" (wich interface R
> <-->
> > GRASS). I need this to make Spatial Analysis
> >
> > So with my two type of script a) and b) , you think Rpy is a good choice
> to
> > manipulate data/query in R and R <-> GRASS ? Have you an experience in
> this
> > type of plateform/architecture?
>
> I've not used these libraries, but one important question is are you
> familiar
> with both R and python?
>
> > 2) I have problem with RPY and connexion with my DB :
> >
> > from rpy import *
> > import math
> >
> > r.library("Rdbi")
> > r.library("RdbiPgSQL")
> >
> > r.dbConnect(r.PgSQL(),host="localhost", dbname="simpop", user="postgres",
> > password="postgres")
> >
> > I have this error message :
> >
> > Traceback (most recent call last):
> > ...
> >   Invalid database class
> >
> > In R, with the same query, no error ...
>
> That is almost certainly due to the default object conversion, the
> most common cause of confusion in rpy beginners.
>
> rPgSQL() returns some database class, which rpy has converted into a
> simplified representation using python objects. You then try and pass
> this back to the r.dbConnect, which means rpy has to try and turn this
> simplified python structure back into R objects. I don't know exactly
> what this will look like (maybe an R list), but
> it won't be a database object!
>
> You should turn off the conversion.
>
> Try something like this:
>
> import rpy
> rpy.set_default_mode(rpy.NO_CONVERSION)
> #your code here:
> rpy.r.library("Rdbi")
> rpy.r.library("RdbiPgSQL")
> rpy.r.dbConnect(rpy.r.PgSQL(),host="localhost", dbname="simpop",
> user="postgres", password="postgres")
> #If you want to go back to the default conversion,
> rpy.set_default_mode(rpy.BASIC_CONVERSION)
>
> Peter
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> rpy-list mailing list
> rpy-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rpy-list
>
------------------------------------------------------------------------------
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to