On Sat, May 23, 2015 at 3:24 AM, Lele Gaifax <l...@metapensiero.it> wrote: > Laura Creighton <l...@openend.se> writes: > >> In my corner of the world, everybody uses SQL. >> [...] >> The people who have tried SQLAlchemy really didn't like it, and of course >> the people who haven't tried it do what their friends do, as usual. > > If these sentences are related, you must live in a very strange corner! > > ;-)
Not sure why. I'm in the same corner, I think - I use SQL, and not SQLAlchemy if I can help it. I'd much rather just use psycopg2 and do my own queries. SQLAlchemy has its uses, and it does solve a number of issues in reasonably clean ways, but I don't like a few of its facets, including its peculiar way of doing foreign key relationships. (You put a foreign key in the child, and you put a relationship in the parent, which feels backwards.) There's a lot of magic going on. When magic works, it's great; but when anything goes wrong, it's harder to see what happened. (Also, when does a transaction begin and end? If you session.commit() in the middle of iterating over a query, will it break the query? What if you roll back? Can you see, instantly, in your code?) Even if the ORM layer is practically perfect in every way, there's still value in learning SQL; for instance, if you drop to a command-line interpreter like PostgreSQL's psql, or if you switch to another language, or anything like that, it's helpful to know what's going on under the covers. And if you have to know SQL anyway, the advantage of the abstraction layer has to justify the cost of learning an additional, not a replacement, API. So, while SQLAlchemy is definitely a lot better than most I've seen, it's still not really good enough for me to use everywhere. I'm mostly going to stick to the Python DB API 2.0. ChrisA -- https://mail.python.org/mailman/listinfo/python-list