本文整理匯總了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])