开发者

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

开发者 https://www.devze.com 2023-01-22 16:04 出处:网络
I\'ve been using SQLObject for a long while, but noticed that SQLAlchemy has become a lot more popu开发者_Go百科lar in the last couple years: http://www.google.com/trends?q=sqlobject,+sqlalchemy

I've been using SQLObject for a long while, but noticed that SQLAlchemy has become a lot more popu开发者_Go百科lar 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消