[R] R ORM?

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Nov 19 19:43:38 CET 2008



Faheem Mitha wrote:
> 
> Hi Hans,
> 
> Thanks for the reply.
> 
> On Tue, 18 Nov 2008, Hans Werner Borchers wrote:
> 
>> Faheem Mitha <faheem <at> email.unc.edu> writes:
>>>
>>> Hi,
>>>
>>> Does anyone know of an R ORM (Object Relational Mapper)? I'm thinking of
>>> something similar to sqlalchemy (http://www.sqlalchemy.org/).
>>> Alternatively or additionally, can people offer suggestions about 
>>> managing
>>> relational databases from R. I'm currently using postgresql, but would
>>> like a flexible solution that works across different databases, hence 
>>> the
>>> enquiry about ORMs.
>>
>> Hi Faheem,
>>
>> I am wondering, what kind of objects or classes you would like to
>> apply the object relational mapper to. S4 classes? -- I doubt that
>> very much.
> 
> Yes. R classes. As long as they support the object oriented paradigm, it 
> doesn't matter too much to me what kind exactly. ORMs map between 
> classes and db tables.
> 
> The attraction of an ORM is high level abstraction capabilities as well 
> as a helping of syntactic sugar.
> 
>> The only reasonable structure for which one could use a mapper in R is
>> the data frame. All R database packages provide support for getting
>> and sending data in data frames to and from databases. Admittedly,
>> this is not what someone from the Python community would accept as an
>> "object relational mapper", but may be sufficient given that there is
>> only this one class concerned.
> 
> You mean eg http://rpgsql.sourceforge.net/ can be used to read and write 
> from a postgresql db, and there are similar packages for mysql etc.?
> 
>> The only way I know to become a somewhat independent from specific
>> databases is to turn to RODBC (Windows or Linux, you didn't say that).

The only way I know is to use standard SQL, and avoid product specific 
extensions in all your code that uses the database.  Even that is not 
perfect, but it is a pretty good start. I don't think RODBC really 
solves this problem for you. It does allow you to talk to different 
products, but so do the various DBI drivers. But in either case, if you 
use product specific extensions then you will tie yourself to the 
product (which is one reason vendors like to add such useful 
extensions).  I read the initial remark to be about porting the database 
itself. In my limited experience this may be a small part compared to 
the code for maintaining and using the database.

Paul
> 
> I use Linux (Debian). You mean 
> http://cran.r-project.org/web/packages/RODBC/index.html? Is this a 
> recommended approach?
> 
> CCing back to list, just in case someone else is interested...
> 
>                                                             Faheem.
> 
> ______________________________________________
> 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.
====================================================================================

La version française suit le texte anglais.

------------------------------------------------------------------------------------

This email may contain privileged and/or confidential in...{{dropped:26}}



More information about the R-help mailing list