【问题标题】:Get SQL query count in peewee在peewee中获取SQL查询计数
【发布时间】:2016-12-08 00:20:15
【问题描述】:

是否可以计算 peewee 中的查询? 如下在 Django 中制作:

from django.db import connection
print len(connection.queries)

【问题讨论】:

    标签: python peewee flask-peewee


    【解决方案1】:

    你可以像here:子类Database一样设置它来计算查询:

    def execute(*args, **kwargs):
        self.counter += 1  # or put the query into some list, as you like
        return super().execute(args, kwargs)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 2021-04-17
      • 1970-01-01
      • 2018-04-25
      相关资源
      最近更新 更多