Why object-relational mapping makes me sad

September 2015

I’ve spent a lot of time lately dealing with SQLAlchemy, which is an object-relational mapper for Python. As you might guess from the title of this post, it makes me kind of sad.

SA’s job is to be an abstraction layer over the database, so that you can write queries as Python functions and get back your results as Python objects. The SQLAlchemy abstraction barrier does act as a barrier in some ways:

On the other hand, it totally punts on some other things:

I’m not claiming that ORMs are necessarily bad on net. We’re almost certainly more productive using SQLAlchemy than if we were writing raw SQL. But I can’t help but feel like there must be something better.


Enjoyed this post? Get notified of new ones via email or RSS. Or comment:

email me replies

format comments in markdown.