Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I be using SQLObject, SQLAlchemy, or SQLAlchemy + Elixir?

I've been using SQLObject for a long while, but noticed that SQLAlchemy has become a lot more popular in the last couple years: http://www.google.com/trends?q=sqlobject,+sqlalchemy

Are there compelling reasons to switch to SQLAlchemy? How is its performance relative to SQLObject? Its usability? And what is the added performance overhead for using Elixir?

My needs are basic, simple CRUD. Nothing exotic.

I've seen this related question, but it was asked 1+ year ago and didn't have much response.

like image 709
mote Avatar asked Nov 01 '10 05:11

mote


1 Answers

I used SqlObject extensively as part of TurboGears 0.9, but switched to SqlAlchemy + elixir as a drop in replacement for SqlObject even before TurboGears did.

Note that even without elixir, SqlAlchemy has it's own declarative style class definitions: http://docs.sqlalchemy.org/en/rel_1_0/orm/extensions/declarative/index.html

If you are unsure about performance, it shouldn't be too much work to drop in elixir as a replacement in your app and do some quick profiling. I'd guess that the performance differences between SqlObject/SQL/SQLA+elixir pale in comparison to the time spent writing and reading data to/from the database.

Note that SqlAlchemy affords much greater control over eager/lazy loading of relationships and columns, which helps the memory footprint & performance of your app in lots of cases.

Probably the most compelling reason to switch is that SqlAlchemy is that it is being actively developed (although I don't know too much about dev status of SqlObject any more). As a secondary reason, you can be assured that if your needs get more complex, it's quite likely that there is someone else that has already attempted to bang the square peg of Python objects into the round hole of SQL successfully with SqlAlchemy.

like image 83
EoghanM Avatar answered Nov 04 '22 13:11

EoghanM