本文整理汇总了Python中pyasm.search.Search.select方法的典型用法代码示例。如果您正苦于以下问题:Python Search.select方法的具体用法?Python Search.select怎么用?Python Search.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sobjects
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import select [as 别名]
def get_sobjects(self):
columns = ['product_name', 'login_id', 'sample_size', 'labor_average']
sql = '''
select "product_name", "login_id", count("total_hours") "sample_size", avg("total_hours") "labor_average"
from (
select "product_type"."id", "product_type"."product_name",
"subtask_product"."product_quantity",
"subtask"."subtask_letter",
"subtask_labor"."total_hours",
"personal_time_log"."login_id"
FROM "product_type"
LEFT OUTER JOIN "subtask_product"
ON "product_type"."id" = "subtask_product"."product_type_id"
INNER JOIN "subtask"
ON "subtask"."id" = "subtask_product"."subtask_id"
INNER JOIN "subtask_labor"
ON "subtask"."id" = "subtask_labor"."subtask_id"
INNER JOIN "personal_time_log"
ON "subtask_labor"."id" = "personal_time_log"."subtask_labor_id"
) X
GROUP BY X."product_name", X."login_id"
'''
db = DbContainer.get("MMS")
from pyasm.search import Select, Search
search_type = self.kwargs.get('search_type')
select = Select()
select.set_statement(sql)
statement = select.get_statement()
search = Search(search_type)
search.select = select
sobjects = search.get_sobjects()
for sobject in sobjects:
sobject.set_value("id", -1)
return sobjects