本文整理汇总了Python中models.Request.select方法的典型用法代码示例。如果您正苦于以下问题:Python Request.select方法的具体用法?Python Request.select怎么用?Python Request.select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Request
的用法示例。
在下文中一共展示了Request.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: details
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import select [as 别名]
def details(id, page=20):
actor = Schedule.select().where(Schedule.id == id).get()
actor_requests = Request.select().where(Request.url_id == id).order_by(Request.insert_date.desc())
pages = PaginatedQuery(actor_requests, page)
content = pages.get_list()
stats = {}
stats['site_changes'] = actor_requests.select(Request.content_len).distinct().count()
stats['total_hits'] = actor_requests.count()
stats['ok_hits'] = actor_requests.select(Request.id).where(Request.status_code == '200').count()
stats['avg_response_time'] = (sum([row.response_time for row in actor_requests])/stats['total_hits'])
return render_template('details.html', actor=actor, actor_requests=content, pages=pages, stats=stats)
示例2: exit
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import select [as 别名]
from models import Request
from models import Schedule
import time
id = 2
requests = Request.select().where(Request.url_id == id).order_by(Request.response_time.desc())
for row in requests:
ms = (int(row.response_time.strftime('%S')) * 1000) + (int(row.response_time.strftime('%f'))/1000)
Request.update(response_time=ms).where(Request.id == row.id).execute()
print "done"
exit()
query = (Request.select(Request, Schedule).join(Schedule, 'LEFT OUTER').limit(10)).sql()
print query
data = Request.raw(query[0])
for row in data:
print row.name
#query = (Request.select(Request, Schedule).join(Schedule).limit(10)).sql()
#data = Request.raw(query[0])