Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The common criticism I hear is that it can't do everything, unlike SqlAlchemy. Fair enough, but the Django ORM is no doubt simpler to use than SqlAlchemy.


SQLAlchemy is designed for people who know SQL already and want a safe and convenient way to use it from Python.

The Django ORM is designed for people that want their Python data objects to be persisted to a back-end data store.

Both of these things have their place. The problem with the Django ORM is sometimes you need to do something slightly more complicated than what it supports and your back to raw SQL. These scenarios are really common, 90% of Django project have raw SQL in them.


SQLAlchemy uses the data mapper pattern whereas django ORM uses active record - that's the main difference. Neither one is really 'better', there are advantages to both approaches:

http://russellscottwalker.blogspot.sg/2013/10/active-record-...

The main advantage to django ORM in my opinion is 'less code', although it does create an excessive coupling between your persistence / model layer. Whether that is something you can live with or not is up to your project's requirements.

I'm pretty happy to work with both. Just don't make me use RoR!


Maybe 5% of the Django projects I've been involved in contain raw SQL.


I've got to disagree with the 90% figure. The vast majority of projects I've seen (which are typically pretty straightforward from a data modeling perspective) rely only on the ORM.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: