本文整理汇总了Python中autonomie_base.models.base.DBSESSION.all方法的典型用法代码示例。如果您正苦于以下问题:Python DBSESSION.all方法的具体用法?Python DBSESSION.all怎么用?Python DBSESSION.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autonomie_base.models.base.DBSESSION
的用法示例。
在下文中一共展示了DBSESSION.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_years
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import all [as 别名]
def get_years(cls, grid_class, company_id=None):
query = DBSESSION().query(distinct(grid_class.year))
if company_id is not None:
query = query.filter_by(company_id=company_id)
result = [a[0] for a in query.all()]
result.sort()
return result
示例2: get_categories
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import all [as 别名]
def get_categories(cls, active=True, keys=()):
"""
:param bool active: Only load active categories
:param tuple keys: The keys to load (list of str)
:returns: IncomeStatementMeasureTypeCategory ordered by order key
:rtype: list
"""
query = DBSESSION().query(cls)
if keys:
query = query.options(load_only(*keys))
query = query.filter_by(active=active).order_by(cls.order)
return query.all()
示例3: get_by_category
# 需要导入模块: from autonomie_base.models.base import DBSESSION [as 别名]
# 或者: from autonomie_base.models.base.DBSESSION import all [as 别名]
def get_by_category(cls, category_id, key=None):
"""
Collect IncomeStatementMeasureType associated to the given category
:param int category_id: The id to check for
:param str key: The key to load (if we want to restrict the query
:rtype: list
"""
query = DBSESSION().query(cls)
if key is not None:
query = query.options(load_only(key))
query = query.filter_by(category_id=category_id)
return query.all()