(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,
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With