【问题标题】:Using Storm ORM, what is the preferable way to count the number of records?使用 Storm ORM,计算记录数的最佳方法是什么?
【发布时间】:2013-10-24 03:37:00
【问题描述】:

标题说明了一切。我尝试浏览 API,但找不到方便的功能。我想了很多方法来做到这一点。我可以调用find() 并计算结果中的记录数。我可以使用 SQLite 数据库并执行 SELECT 和计数。

【问题讨论】:

  • 我最终使用了store.execute("SELECT COUNT(*) FROM table").get_one() 似乎没有更好的方法。

标签: python sqlite storm-orm


【解决方案1】:

如果您以后会回到这个问题,请不要,但是...

store.find(User).count()

python 控制台是您的朋友。这将为您提供对象的所有属性...

dir(store.find(User))

这将显示它返回的类,以便您查看 api 文档...

store.find(User).__class__

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-26
    • 2015-08-21
    相关资源
    最近更新 更多