Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a package for object-relational mapping in R?

Tags:

r

orm

dplyr

rmysql

(By object-relational mapping, I mean what is described here: Wikipedia: Object-relational mapping.)

Here is how I could imagine this work in R : a kind of "virtual data frame" is linked to a database, and returns the results of SQL queries when accessed. For instance, head(virtual_list) would actually return the results of (select * from mapped_table limit 5) on the mapped database.

I have found this post by John Myles White, but there seems to have been no progress in the last 3 years.

Is there a working package that implements this ?

If not,

  1. Would it be useful ?
  2. What would be the best way to implement it (S4 ?) ?
like image 680
nassimhddd Avatar asked Aug 16 '12 13:08

nassimhddd


People also ask

Which is object relational mapping library?

An object-relational mapper (ORM) is a code library that automates the transfer of data stored in relational database tables into objects that are more commonly used in application code.

What is an object relational mapping tool?

Object–relational mapping (ORM, O/RM, and O/R mapping tool) in computer science is a programming technique for converting data between type systems using object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language.

Is object relational mapping library in Ruby?

ORM - Object Relational Mapping is a framework written in OOP Languages such as Java, Python, and Ruby. This framework wraps around a relational database such as MySQL.


1 Answers

The very recent package dplyr is implementing this (amongst other amazing features).

Here are illustrations from the examples of function src_mysql():

# Connection basics ---------------------------------------------------------
# To connect to a database first create a src:
my_db <- src_mysql(host = "blah.com", user = "hadley",
  password = "pass")
# Then reference a tbl within that src
my_tbl <- tbl(my_db, "my_table")

# Methods -------------------------------------------------------------------
batting <- tbl(lahman_mysql(), "Batting")
dim(batting)
colnames(batting)
head(batting)
like image 53
nassimhddd Avatar answered Sep 16 '22 17:09

nassimhddd