We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed last year.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
我在 TurboGears 0.9 中广泛使用了 SqlObject,但在 TurboGears 之前就切换到了 SqlAlchemy + elixir 作为 SqlObject 的替代品。
请注意,即使没有 elixir,SqlAlchemy 也有自己的声明式风格的类定义:
http://docs.sqlalchemy.org/en/rel_1_0/ orm/extensions/declarative/index.html
如果您不确定性能,那么在您的应用程序中放入 Elixir 作为替代品并进行一些快速分析应该不会有太多工作。我猜想与从数据库写入和读取数据所花费的时间相比,SqlObject/SQL/SQLA+elixir 之间的性能差异微不足道。
请注意,SqlAlchemy 对 关系 的急切/延迟加载提供了更大的控制和列,这有助于内存占用和在很多情况下你的应用程序的性能。
也许最令人信服的切换原因是 SqlAlchemy 正在积极开发(尽管我不再了解 SqlObject 的开发状态)。
作为次要原因,您可以放心,如果您的需求变得更加复杂,很可能已经有人尝试使用 SqlAlchemy 将 Python 对象的方钉成功地插入 SQL 的圆孔中。
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.