当前位置: 首页>>代码示例>>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;未经允许,请勿转载。