3 ms·
I've been using various ORMs for the last 6 years (Django ORM, SQLAlchemy and EntitySpaces are the ones at the top of my head) and only in very rare occasions I
by dguaraglia 14y ago
I've been using various ORMs for the last 6 years (Django ORM, SQLAlchemy and EntitySpaces are the ones at the top of my head) and only in very rare occasions I've had to write my own SQL code to cover a case the ORM wouldn't cover.
A big issue nobody is addressing here is that using "pure SQL" requires you to use crappy data structures (say, a dictionary, "associative array" or, most likely, a simple array in languages like C/C++) to access and push the data. So, instead of having something simple like:
user = User.objects.get(username='ecopoesis')
...
# 100 lines of business logic that uses the 'user' object.
# Methods like 'set_password' that calculates a hash of a
# password and stores it in the object make my life much easier
# by keeping the logic close to the data.
...
user.save()
I first have to go through a bunch of boilerplate to read the data, put it in some easy-to-use container where I can keep my logic tied to the data, and then construct an SQL statement by concatenating strings.