What are the benefits of using Elixir

... against declarative sqlalchemy?

+7
python sqlalchemy python-elixir
source share
3 answers

I started here with a list of the practical (technical) differences / advantages of the elixir versus sqlalchmey, but I don’t know, the claims are fair because my knowledge of sqlalchemy is very limited (I use a very small part of the elixir and sqla).

It would be very convincing that the answers show a sample code in sqla and an equivalent in elixir to show the differences, as some answers to questions were compared here in stackoverflow (I think, for example, mako vs jinja2)

Anyway, here is my list, I would really appreciate it if people corrected me (correct my assumptions about sqlalchemy)

  • Elixir implements an active recording template and is intended to replace the ActiveMapper SQLAlchemy extension. (from date: sqlalchemy caught up?)

  • The b / w relationships of the models are understandable (er): OneToMany, ManyToOne, ManyToMany and OneToOne are clearer than the sqla relation. At a glance you can see the b / w relationships of your models.

  • The skill is more convenient than in sqlalchemys. This is also more noticeable as you get the lessons. In sqla, you have to configure the attributes of polymorphic and polymorphic_contacts.

  • Inhertience: in elixir, tables, columns and foreign keys are created automatically, but not in sqlalchemy. (100% right?)

  • Elixir automatically creates an identifier column for all tables (if no other primary_key is declared)

  • Elixir automatically creates FK for relationships, sql not (?)

  • In elixir, more often than not, you do not need to specify backref in your relationship. In sqla you should always (?)

  • Elixir has a version extension (sql not?)

  • Elixir has an associative extension that creates ManyToMany relationships and provides good select_by_XXX methods, where XXX is the name of the associated class. Sqla dosen't has this kind of extension (?)

  • Relationship inheritance is transparent in Elixir. In sqla this is not the case, you have to do this: http://www.sqlalchemy.org/docs/reference/ext/declarative.html#mixing- ... )

+5
source share

We can say that Elixir was created because SQLAlchemy is not declarative enough for some people.

On the Elixir website:

The elixir is intended to replace the SQLAlchemy ActiveMapper extension and the TurboEntity project, but does not intend to replace the core SQLAlchemy functions, but instead focuses on providing a simpler syntax for defining model objects when you do not need full expressiveness SQLAlchemy map control definitions.

+2
source share

The Elixir syntax is what I find useful when creating a database for a given application from scratch, and all this has been figured out in advance.

I had better luck with SQLAlchemy when using it in legacy databases (and on other similarly logically immutable schemas). The SQLSoup plugin is especially useful, for one-time subtraction of read-only data, in preparation for its migration to another place.

YMMV, but Elixir is not really designed to adapt to older schemas - and SQLAlchemy overflows correctly for most small and medium sized projects (in my opinion, of course).

+1
source share

All Articles