Thoughts on SQL vs ORM

Alec Taylor alec.taylor6 at gmail.com
Wed Feb 6 13:15:20 EST 2013


I agree that ORMs can be rather complicated; especially when you need
to do some refactoring.

Another reason not to use ORMs is difficult of measuring query complexity.

However, some of the most major advantages of ORMs are:
- Generation of forms
- Same code can be used with multiple backends
- The different data abstraction can sometimes be useful

Personally for my projects I don't use an ORM. I use a DAL: Database
Abstraction Layer, specifically the one from web2py (usable with a
variety of competing frameworks including Flask).

This has the advantages of:
- Generation of forms
- Same code can be used with multiple backends
- More concise query construction, using Python language concepts
- Extremely easy to measure query complexity and amount of data that
will be manipulated (compare this to Django's ORM; which essentially
requires use of DDT)

Just my 2¢

On Wed, Feb 6, 2013 at 11:58 PM, Andriy Kornatskyy
<andriy.kornatskyy at live.com> wrote:
>
> The question of persistence implementation arise often. I found repository pattern very valuable due to separation of concerns, mediate between domain model and data source (mock, file, database, web service, etc).
>
> The database data source is somewhat specific since you can proceed with SQL functions or ORM. Here are some thoughts why you might prefer SQL functions over ORM in your next project:
>
> http://mindref.blogspot.com/2013/02/sql-vs-orm.html
>
> Comments or suggestions are welcome.
>
> Thanks.
>
> Andriy Kornatskyy
> --
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list