当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.query方法代码示例

本文整理汇总了Python中pyrtos.models.meta.DBSession.query方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.query方法的具体用法?Python DBSession.query怎么用?Python DBSession.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyrtos.models.meta.DBSession的用法示例。


在下文中一共展示了DBSession.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: all_queryed

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
    def all_queryed(cls,
                    ucid,
                    qry=False,
                    cats=False,
                    creds=False,
                    total_only=False,
                    fromdate=False,
                    todate=False,):
        base = DBSession.query(Invoice)
        if total_only:
            base = DBSession.query(func.sum(Invoice.amount).label('a_sum'))\

        base = base.join(Invoice.category)\
                   .join(Invoice.creditor)\
                   .filter(not_(and_(Category.private == True,
                                     Category.user_id != ucid)))

        """ if argument add filter(s)."""
        if qry:
            qry = "%"+qry+"%"
            base = base.filter(Invoice.title.like(qry))
        if cats:
            for c in cats:
                base = base.filter(Category.id == c.id)
        if creds:
            for c in creds:
                base = base.filter(Creditor.id == c.id)
        if fromdate:
            base = base.filter(Invoice.due >= fromdate)
        if todate:
            base = base.filter(Invoice.due <= todate)
        return base
开发者ID:plastboks,项目名称:Pyrtos,代码行数:34,代码来源:invoice.py

示例2: with_category

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def with_category(cls, id, total_only=False):
     if total_only:
         return DBSession.query(func.sum(Expenditure.amount)
                                    .label('a_sum'))\
                         .filter(and_(Expenditure.archived == False,
                                      Expenditure.category_id == id))\
                         .first()
     return DBSession.query(Expenditure)\
                     .filter(and_(Expenditure.category_id == id,
                                  Expenditure.archived == False)).all()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:12,代码来源:expenditure.py

示例3: with_category_all_unpaid

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
    def with_category_all_unpaid(cls, cid, total_only=False):
        base = DBSession.query(Invoice)

        if total_only:
            base = DBSession.query(func.sum(Invoice.amount).label('a_sum'))\

        base = base.filter(and_(Invoice.category_id == cid,
                                Invoice.archived == False,
                                Invoice.paid == None))\
                   .all()
        return base
开发者ID:plastboks,项目名称:Pyrtos,代码行数:13,代码来源:invoice.py

示例4: with_category_paid

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
    def with_category_paid(cls, cid, year, month, total_only=False):
        base = DBSession.query(Invoice)

        if total_only:
            base = DBSession.query(func.sum(Invoice.amount).label('a_sum'))\

        base = base.filter(and_(Invoice.category_id == cid,
                                Invoice.archived == False,
                                Invoice.paid != None))\
                   .filter(extract('year', Invoice.due) == year)\
                   .filter(extract('month', Invoice.due) == month)\
                   .all()
        return base
开发者ID:plastboks,项目名称:Pyrtos,代码行数:15,代码来源:invoice.py

示例5: all_active

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def all_active(cls, request, id=False):
     if not id:
         id = authenticated_userid(request)
     return DBSession.query(Creditor)\
                     .filter(Creditor.archived == False)\
                     .filter(not_(and_(Creditor.private == True,
                                       Creditor.user_id != id)))
开发者ID:plastboks,项目名称:Pyrtos,代码行数:9,代码来源:creditor.py

示例6: all_private

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def all_private(cls, request, id=False):
     if not id:
         id = authenticated_userid(request)
     return DBSession.query(Category)\
                     .filter(and_(Category.user_id == id,
                                  Category.private == True,
                                  Category.archived == False))
开发者ID:plastboks,项目名称:Pyrtos,代码行数:9,代码来源:category.py

示例7: first_private

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def first_private(cls, request):
     id = authenticated_userid(request)
     return DBSession.query(Creditor)\
                     .filter(and_(Creditor.archived == False,
                                  Creditor.private == True,
                                  Creditor.user_id == id)).first()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:8,代码来源:creditor.py

示例8: all_archived

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def all_archived(cls, ucid):
     return DBSession.query(Invoice)\
                     .join(Invoice.category)\
                     .filter(Invoice.archived == True)\
                     .filter(not_(and_(Category.private == True,
                                       Category.user_id != ucid)))
开发者ID:plastboks,项目名称:Pyrtos,代码行数:8,代码来源:invoice.py

示例9: all_active

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def all_active(cls):
     return DBSession.query(User).filter(User.archived == False)
开发者ID:plastboks,项目名称:Pyrtos,代码行数:4,代码来源:user.py

示例10: by_email

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def by_email(cls, email):
     return DBSession.query(User).filter(User.email == email).first()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:4,代码来源:user.py

示例11: all_archived

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def all_archived(cls, request):
     id = authenticated_userid(request)
     return DBSession.query(File)\
                     .filter(File.archived == True)\
                     .filter(not_(and_(File.private == True,
                                       File.user_id != id)))
开发者ID:plastboks,项目名称:Pyrtos,代码行数:8,代码来源:file.py

示例12: all_shared

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def all_shared(cls):
     return DBSession.query(Category)\
                     .filter(Category.archived == False)\
                     .filter(Category.private == False)
开发者ID:plastboks,项目名称:Pyrtos,代码行数:6,代码来源:category.py

示例13: first_active

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def first_active(cls):
     return DBSession.query(Category)\
                     .filter(and_(Category.archived == False,
                                  Category.private == False)).first()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:6,代码来源:category.py

示例14: by_id

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def by_id(cls, id):
     return DBSession.query(Category).filter(Category.id == id).first()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:4,代码来源:category.py

示例15: by_id

# 需要导入模块: from pyrtos.models.meta import DBSession [as 别名]
# 或者: from pyrtos.models.meta.DBSession import query [as 别名]
 def by_id(cls, id):
     return DBSession.query(Tag).filter(Tag.id == id).first()
开发者ID:plastboks,项目名称:Pyrtos,代码行数:4,代码来源:tag.py


注:本文中的pyrtos.models.meta.DBSession.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。