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