Django orm vs sqlachemy, are they basically the same thing?

When using django, I believe that you can change the built-in orm to sqlalchemy (don't know how to do this?).

Are they both basically the same or is there a clear winner between 2?

+4
source share
2 answers

When using django, I believe that you can change the built-in orm to sqlalchemy (don't know how to do this?).

You can use SQLAlchemy in your Django applications. This does not mean that you can "change" ORM. Some of the built-in Django batteries will stop working if you completely replace the Django ORM SQLAlchemy. For example, the admin application does not work.

I read about people using both. Django ORM to make batteries work, and SQLAlchemy to solve complex SQL relationships and queries.

Are they both basically the same or is there a clear winner between 2?

This is not the same thing. SQLAlchemy is more versatile than Django ORM. For example, while Django ORM tightly connects the business logic layer and the persistence layer in models, SQLAlchemy allows you to save them separately.

SQLAlchemy, on the other hand, has a steeper learning curve and will be redundant for many projects. Existing migration tools for SQLAlchemy may not integrate seamlessly with Django.

Everyone said, I would not declare a "winner". They are widely similar tools, but have their own strengths and weaknesses and the best situations.

As long as you answer this question, it would not hurt to read this (dated, but current) message about short messages about Django ORM and how it compares with SQLAlchemy.

+6
source

SQLAlchemy is more powerful, but also more complex than Django ORM.

Elixir provides an interface on top of SQLAlchemy, which is closer to Django ORM in terms of complexity, but also allows you to use SQLAlchemy constructs if Elixir is not enough. For example, I found the SQLAlchemy AssociationProxy class to be useful in several cases. You just drop the AssociationProxy field into the Elixir model class, and you're good to go.

0
source

All Articles