Django ORM & DB backend coupling

232 views
Skip to first unread message

Rakan Alhneiti

unread,
Dec 24, 2013, 10:15:10 AM12/24/13
to django...@googlegroups.com
Hello all,

I was discussing the topic with a couple of my friends that Django's ORM is / is not tightly coupled with databases in general. My point of view was that django is not tightly coupled because you can write custom DB backends to deal with other sources of data such as a Restful API service while still taking advantage of the ORM.
However, looking at the current architecture & implementation, i guess i can say that it is coupled because writing a custom backend would require you to write database-specific classes such as the DatabaseWrapper, Operations, Features .. etc.

Is wiring Django's ORM with a Restful API service rather than MySQL or Postgresql a good idea? or the better one would be writing ORMs from scratch that are API-based rather than database-driven? 

Please share with me your thoughts on this topic.

Regards,
Rakan

Andrew Farrell

unread,
Dec 24, 2013, 10:30:10 AM12/24/13
to django...@googlegroups.com
This seems like it would be a reasonable idea if the API represented a data model that was fundamentally relational in character. However, many are not. An API should be designed such that it is the best way to interact with its data model, so trying to shoehorn it into an ORM's API seems like it would make it less usable.

For what reasons would one want to use a REST API through the functions exposed by the ORM and not through the python API itself?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0f0d7924-3554-4052-bfb0-5c447282845f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Rakan Alhneiti

unread,
Dec 24, 2013, 10:45:42 AM12/24/13
to django...@googlegroups.com
Good points. The case at hand takes place when thinking about developing a django application on top of a service-oriented backend system that provides you with CRUD operations for data and abstracting the DB engine or storage mechanism that this backend is using. It does make sense to integrate this with the ORM to me but i find it quite strange that django is that coupled to mostly relational database engine reflected by it's architecture.

Marc Aymerich

unread,
Dec 24, 2013, 12:36:08 PM12/24/13
to django-users
I actually ended up implementing a "REST ORM" from scratch, but
heavily inspired by Django's ORM. I managed to spend a couple of weeks
on it, but now the project is dead. You may want to take a look at it
anyway:

http://confine-orm.readthedocs.org/
http://redmine.confine-project.eu/projects/confine-orm/repository

The main difference with Django is that resource schema is not
predefined, but discovered while browsing the API. Also the API for
what it was developed for did not support filtering, so it does
client-side filtering with heavy use of concurrency.

Don't really know how much you'll need to sacrifice in order to fit a
REST service within a Django ORM backend. It could be fun to do it,
but leveraging all its potential seems quite difficult at first look,
I would say it's not worth the trouble :)

--
Marc

Marc Aymerich

unread,
Dec 24, 2013, 12:49:57 PM12/24/13
to django-users
On Tue, Dec 24, 2013 at 4:15 PM, Rakan Alhneiti
<rakan.a...@gmail.com> wrote:
You may want to take a look at a recent discussion at django-dev about
this subject

https://groups.google.com/forum/#!msg/django-developers/zlLCJ5HC3c8/7eFdmdUSDbsJ


--
Marc
Reply all
Reply to author
Forward
0 new messages