本文整理匯總了Python中por.models.DBSession.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python DBSession.execute方法的具體用法?Python DBSession.execute怎麽用?Python DBSession.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類por.models.DBSession
的用法示例。
在下文中一共展示了DBSession.execute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: fetch_done
# 需要導入模塊: from por.models import DBSession [as 別名]
# 或者: from por.models.DBSession import execute [as 別名]
def fetch_done(self, projects):
cr_done = collections.defaultdict(lambda: datetime.timedelta(0))
for project in projects:
ticket_crs = ticket_store.get_all_ticket_crs(project, self.request)
sql = sa.text("""
SELECT ticket, hours
FROM time_entries
WHERE ticket IS NOT NULL
AND project_id = :project_id
""").params(project_id=project.id)
for ticket_id, hours in DBSession.execute(sql):
try:
cr_id = ticket_crs[ticket_id]
cr_done[cr_id] += hours
except KeyError:
# likely a ticket with no CR
pass
return cr_done