4 ms·
And I used to think like that. As if I was giving up potential. So I went through this SQLAlchemy core phase (http://docs.sqlalchemy.org/en/latest/core/tutorial
by git-pull 10y ago
And I used to think like that. As if I was giving up potential. So I went through this SQLAlchemy core phase (http://docs.sqlalchemy.org/en/latest/core/tutorial.html http://docs.sqlalchemy.org/en/latest/core/tutorial.html). Though, never back to writing raw SQL, but I did some of that back in 2002-2003. And despite being challenged by colleagues skeptical of ORM's, I've yet to see a shortcoming for using an ORM in web development frameworks in python.
In fact I'm coming short on a value equation where it'd be more secure / efficient / readable without at least a query builder.
> but ORM means giving up a lot of control
What control is being lost, specifically?
> (and transparency, and understanding)
Highly recommend Django in Depth by James Bennett at PyCon 2015. https://www.youtube.com/watch?v=tkwZ1jG3XgA https://www.youtube.com/watch?v=tkwZ1jG3XgA
Also, try out printing the .query of the QuerySet:
print(MyUser.objects.all().query)
SELECT "core_myuser"."id", "core_myuser"."password", "core_myuser"."last_login", "core_myuser"."is_superuser", "core_myuser"."username", "core_myuser"."email", "core_myuser"."is_active", "core_myuser"."is_admin" FROM "core_myuser"
And Q(), https://docs.djangoproject.com/en/1.11/topics/db/queries/#complex-lookups-with-q-objects https://docs.djangoproject.com/en/1.11/topics/db/queries/#co..., .extra(), https://docs.djangoproject.com/en/1.11/ref/models/querysets/#extra https://docs.djangoproject.com/en/1.11/ref/models/querysets/..., and finally raw SQL queries https://docs.djangoproject.com/en/1.11/topics/db/sql/ https://docs.djangoproject.com/en/1.11/topics/db/sql/.
> of your database in exchange for a few shortcuts regarding things like M:M links.
Maybe a few other benefits: helps with readability, consistent with OOP in python. Works across SQL dialects. Prevents mistakes, since those relationships are common. Getting clear and consistent access to common data retrieval and updating.