4 ms·
I was recently learning Ecto - Elixir's DB integration library - and its design, to my untrained eyes, looked very similar to SQLAlchemy. Especially the way of
by klibertp 6y ago
I was recently learning Ecto - Elixir's DB integration library - and its design, to my untrained eyes, looked very similar to SQLAlchemy. Especially the way of writing queries looked almost identical. I never actually used either, just read a bunch of tutorials for both, so I'd be happy to hear an informed opinion: is the similarity superficial, or is Ecto modeled after SQLAlchemy? Or do they both implement a pattern which predates them both?
- madelyn 6y agoYou can use SQLAlchemy like Ecto or in a functional manner, especially with core. But a lot of projects I've seen around the web try to bend the sqlalchemy ORM into a more "active record" way of working.
- bitwalker 6y agoI believe Ecto is largely inspired by LINQ from C#, but I wouldn't be surprised if SQLAlchemy was an inspiration as well.
- lawik 6y agoI dare say that Ecto does a lot of things quite differently. From my work with SQLAlchemy I never saw anything similar to changesets. I love working with Elixir but I would probably say that I found building queries in SQLAlchemy a bit more straight-forward than in Ecto. While I'd rather do basically everything else in Ecto. I think most of the similarities is because they are both providing abstraction on top SQL, which tends to lead to a similar enough API surface. I don't know what primarily influenced Ecto. But I think it was quite intentionally not Django ORM or ActiveRecord. Working with Ecto and SQLAlchemy at different times I don't find them very similar beyond all the SQL terminology and API surface they share. So yeah, maybe superficial, and yes an older pattern, SQL ;) SQLAlchemy + Alembic cover a very large feature set for ORM, query building, migrations and all of that stuff in a way I think works pretty darn well. It simplifies building SQL queries piece by piece but gets very complex for certain queries.