本文整理汇总了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
示例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()
示例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
示例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
示例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)))
示例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))
示例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()
示例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)))
示例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)
示例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()
示例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)))
示例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)
示例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()
示例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()
示例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()