當前位置: 首頁>>代碼示例>>Python>>正文


Python Session.query方法代碼示例

本文整理匯總了Python中pvscore.model.meta.Session.query方法的典型用法代碼示例。如果您正苦於以下問題:Python Session.query方法的具體用法?Python Session.query怎麽用?Python Session.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pvscore.model.meta.Session的用法示例。


在下文中一共展示了Session.query方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: find_by_name

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_name(site, name, cached=True):
     if cached:
         return Session.query(Content)\
             .options(FromCache('Content.find_by_name', "%s/%s" % (site.site_id, name)))\
             .filter(and_(Content.site == site,
                          Content.name == name,
                          Content.delete_dt == None)).first()
     else:
         return Session.query(Content)\
             .filter(and_(Content.site == site,
                          Content.name == name,
                          Content.delete_dt == None)).first()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:14,代碼來源:content.py

示例2: find_payments_by_order

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_payments_by_order(order):
     return Session.query(Journal).filter(and_(Journal.customer==order.customer,
                                              Journal.order==order,
                                              Journal.delete_dt == None,
                                              or_(Journal.type=='PartialPayment',
                                                  Journal.type=='FullPayment')))\
                                              .order_by(Journal.create_dt.desc()).all()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:journal.py

示例3: find_by_user

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_user(user):
     return (
         Session.query(Appointment)
         .filter(or_(Appointment.creator == user, Appointment.assigned == user))
         .order_by(Appointment.start_dt.asc(), Appointment.start_time.asc())
         .all()
     )
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:appointment.py

示例4: find_by_customer

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_customer(customer):
     return (
         Session.query(Appointment)
         .filter(Appointment.customer == customer)
         .order_by(Appointment.start_dt.desc(), Appointment.start_time.asc())
         .all()
     )
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:appointment.py

示例5: find

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find(attr, fk_id):
     #pylint: disable-msg=E1101
     #TODO: Fix attribute value caching:  .options(FromCache('AttributeValue.find.%s.%s' % (attr.attr_id, fk_id)))\
     return Session.query(AttributeValue)\
         .filter(and_(AttributeValue.fk_type == attr.fk_type,
                      AttributeValue.fk_id == fk_id,
                      AttributeValue.attr_id == attr.attr_id)).first()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:attribute.py

示例6: find_all

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_all(enterprise_id):
     #pylint: disable-msg=E1101
     return Session.query(Campaign) \
         .options(FromCache('Campaign.find_all', enterprise_id)) \
         .join((Company, Campaign.company_id == Company.company_id)).filter(and_(Campaign.delete_dt == None,
                                                                                 Company.enterprise_id == enterprise_id)) \
                                                                                 .order_by(Company.default_campaign_id.desc(), Campaign.name).all()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:campaign.py

示例7: find_all

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_all(enterprise_id):
     return Session.query(Vendor).options(FromCache('Vendor.find_all', enterprise_id)) \
         .filter(and_(Vendor.delete_dt == None, 
                      Vendor.enterprise_id == enterprise_id
                      )) \
                      .order_by(Vendor.name) \
                      .all()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:purchase.py

示例8: find

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find(email, campaign):
     """ KB: [2010-12-15]: Find another customer that is in the same company. """
     from pvscore.model.crm.campaign import Campaign
     return Session.query(Customer).join((Campaign, Campaign.campaign_id == Customer.campaign_id)) \
         .filter(and_(Customer.delete_dt == None,
                      Campaign.company_id == campaign.company_id,
                      Customer.email.ilike(email))).first()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:customer.py

示例9: find_by_customer

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_customer(customer, order_id):  # =None, start_dt=None, end_dt=None):
     if order_id:
         return (
             Session.query(CustomerOrder)
             .filter(and_(CustomerOrder.customer == customer, CustomerOrder.order_id == order_id))
             .first()
         )
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:9,代碼來源:customerorder.py

示例10: find_all_applicable

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_all_applicable(enterprise_id, obj):
     # KB: [2010-11-29]: Eventually this will get more complex and base its
     # behavior off the current state of the customer.
     return Session.query(StatusEvent)\
         .filter(and_(or_(StatusEvent.enterprise_id == enterprise_id, StatusEvent.enterprise_id == None),
                      StatusEvent.is_system == False,
                      StatusEvent.event_type == type(obj).__name__))\
                      .order_by(StatusEvent.short_name, StatusEvent.event_type).all()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:10,代碼來源:statusevent.py

示例11: find_for_object

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_for_object(obj):
     fk_type = type(obj).__name__
     fk_id = getattr(obj, obj.__pk__)
     #pylint: disable-msg=E1101
     return Session.query(Asset) \
         .options(FromCache('Asset.find_for_object', '%s/%s' % (fk_type, fk_id))) \
         .filter(and_(Asset.fk_type == fk_type,
                      Asset.fk_id == fk_id)).all()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:10,代碼來源:asset.py

示例12: find_all_active

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_all_active(enterprise_id, web_enabled=True):
     return Session.query(Discount) \
         .filter(and_(Discount.delete_dt == None, 
                      Discount.enterprise_id == enterprise_id,
                      Discount.web_enabled == web_enabled,
                      or_(Discount.end_dt == None,
                          Discount.end_dt >= util.now())))\
                          .order_by(Discount.name) \
                          .all() 
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:11,代碼來源:discount.py

示例13: find_by_code

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_code(enterprise_id, code):
     return Session.query(Discount)\
         .filter(and_(Discount.enterprise_id == enterprise_id,
                      Discount.delete_dt == None,
                      Discount.code.ilike(code),
                      or_(Discount.end_dt == None,
                          Discount.end_dt >= util.now())))\
                          .order_by(Discount.create_dt) \
                          .first() 
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:11,代碼來源:discount.py

示例14: find_by_product

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_product(product):
     return Session.query(Discount)\
         .join((DiscountProduct, DiscountProduct.discount_id == Discount.discount_id))\
         .filter(and_(DiscountProduct.product == product,
                      Discount.delete_dt == None,
                      or_(Discount.end_dt == None,
                          Discount.end_dt > util.today())))\
                          .order_by(Discount.create_dt.desc())\
                          .first()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:11,代碼來源:discount.py

示例15: find_by_product

# 需要導入模塊: from pvscore.model.meta import Session [as 別名]
# 或者: from pvscore.model.meta.Session import query [as 別名]
 def find_by_product(product):
     return Session.query(PurchaseOrderItem)\
         .join((PurchaseOrder, PurchaseOrder.purchase_order_id == PurchaseOrderItem.purchase_order_id)) \
         .filter(and_(PurchaseOrder.delete_dt == None, 
                      PurchaseOrderItem.delete_dt == None,
                      PurchaseOrderItem.product == product
                      )) \
                      .order_by(PurchaseOrder.create_dt.desc()) \
                      .all()
開發者ID:anonymoose,項目名稱:pvscore,代碼行數:11,代碼來源:purchase.py


注:本文中的pvscore.model.meta.Session.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。