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


Python DBSession.query方法代碼示例

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


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

示例1: get

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def get(self, idx = None, name = None):
     log.debug("get place by id: {0}, name: {1}", idx, name)
     place = None
     try:
         if idx:
             place = DBSession.query(Place).filter_by(id = int(idx)).first()
         elif name:
             place = DBSession.query(Place).filter_by(name = name).first()
     except Exception as ex:
         log.exception(ex)
     return place
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:13,代碼來源:placesfacade.py

示例2: get

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def get(self, idx = None, name = None, group = None):
     log.debug("get")
     org = None
     try:
         if group is not None:
             org = DBSession.query(Group).filter_by(id = group.id).first()
         elif idx is not None:
             org = DBSession.query(Group).filter_by(id = int(idx)).first()
         elif name is not None:
             org = DBSession.query(Group).filter_by(name = name).first()
     except Exception as ex:
         log.exception(ex)
     return org
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:15,代碼來源:groupsfacade.py

示例3: count

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def count(self):
     log.debug("count")
     try:
         return DBSession.query(SetupDictionary.id).count()
     except Exception as ex:
         log.exception(ex)
         return -1
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:9,代碼來源:settingsfacade.py

示例4: search

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def search(self, phrase, orderby):
     log.debug("search")
     query = DBSession.query(User)
     if phrase:
         query = self.query_like(phrase)
     if orderby:
         query = self.query_like(orderby)
     return query.all()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:10,代碼來源:usersfacade.py

示例5: get_group_users

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def get_group_users(self, id = None, name = None):
     log.debug("get_group_users")
     response = Return()
     try:
         id = id if id else self.get(name = name).id
         if id:
             uig = DBSession.query(UserInGroup).filter_by(group_id = id).all()
             if uig:
                 ids = [item.user_id for item in uig]
                 response.data = DBSession.query(User).filter(User.id.in_(ids)).all()
                 response.success()
         else:
             response.notfound()
             log.warn(response.msg)
     except Exception as ex:
         log.exception(ex)
         response.exception
     return response
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:20,代碼來源:groupsfacade.py

示例6: all

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def all(self, limit = 500):
     log.debug("all")
     response = Return()
     limit = 500
     data = []
     try:
         response.data = DBSession.query(History).order_by(History.date.desc()).limit(limit).all()
         response.success()
     except Exception as ex:
         log.exception(ex)
         response.exception()
     return response
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:14,代碼來源:historyfacade.py

示例7: get_counts

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def get_counts():
     groups_len = self.groups_facade.count()
     users_len = DBSession.query(User.id).count()
     histories_len = self.history.count()
     settings_len = self.settings.count()
     places_len = self.places.count()
     return dict(status= True, msg="OK", 
         groups_count = groups_len, 
         users_count = users_len, 
         histories_count = histories_len,
         places_count = places_len,
         settings_count = settings_len)
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:14,代碼來源:views.py

示例8: get_all

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def get_all(self):
     log.debug("all")
     result = Return()
     try:
         result.data = []
         for user in DBSession.query(User).all():
             result.data.append(self.get_details(user))
         result.success()
     except Exception as ex:
         log.exception(ex)
         result.exception()
     return result
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:14,代碼來源:usersfacade.py

示例9: clean

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def clean(self):
     log.debug("clean")
     result = Return()
     try:
         if self.count > 0:
             result.data = DBSession.query(History).delete()
         result.success()
         log.info(result.msg)
     except Exception as ex:
         log.exception(ex)
         result.exception()
     return result
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:14,代碼來源:historyfacade.py

示例10: by_login

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def by_login(self, login):
     log.debug("by_login")
     return DBSession.query(Account).filter_by(login = login).one()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:5,代碼來源:accountfacade.py

示例11: by_identifier

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def by_identifier(self, identifier):
     log.debug("by_identifier")
     return DBSession.query(Account).filter_by(identifier = identifier).one()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:5,代碼來源:accountfacade.py

示例12: count

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def count(self):
     ''' Gets number of accounts '''
     log.debug("count")
     return DBSession.query(Account.id).count()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:6,代碼來源:accountfacade.py

示例13: by_name

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def by_name(self, name):
     log.debug("by_name")
     if not(name):
         return None
     return DBSession.query(User).filter_by(name = name).first()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:7,代碼來源:usersfacade.py

示例14: like

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def like(self, search):
     log.debug("like")
     return DBSession.query(Group).filter(Group.name.like('%{0}%'.format(search))).all()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:5,代碼來源:groupsfacade.py

示例15: by_name

# 需要導入模塊: from bproject.models.models import DBSession [as 別名]
# 或者: from bproject.models.models.DBSession import query [as 別名]
 def by_name(self, name):
     log.debug("by_name")
     return DBSession.query(Group).filter_by(name = name).all()
開發者ID:bartoszp32,項目名稱:BProject,代碼行數:5,代碼來源:groupsfacade.py


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