本文整理汇总了Python中models.DBSession.filter方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.filter方法的具体用法?Python DBSession.filter怎么用?Python DBSession.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.DBSession
的用法示例。
在下文中一共展示了DBSession.filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_log_entries
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import filter [as 别名]
def get_log_entries(tank_id=None, timerange=None):
""" Get a list of LogEntry objects """
query = DBSession().query(LogEntry)
if tank_id is not None:
query = query.filter(LogEntry.tank_id == tank_id)
if timerange is not None:
if 'start' in timerange:
query = query.filter(LogEntry.entry_time >= timerange['start'])
if 'end' in timerange:
query = query.filter(LogEntry.entry_time <= timerange['end'])
return query.order_by(LogEntry.entry_time.asc()).all()
示例2: get_measurements
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import filter [as 别名]
def get_measurements(tank_id=None, parameters=None, timerange=None):
""" Get a list of Measurements """
query = DBSession().query(Measurement)
if tank_id is not None:
query = query.filter(Measurement.tank_id == tank_id)
if parameters is not None:
query = query.filter(Measurement.measurement_type_id.in_(parameters))
if timerange is not None:
if 'start' in timerange:
query = query.filter(Measurement.measurement_time >= timerange['start'])
if 'end' in timerange:
query = query.filter(Measurement.measurement_time <= timerange['end'])
return query.order_by(Measurement.measurement_time.asc()).all()
示例3: get
# 需要导入模块: from models import DBSession [as 别名]
# 或者: from models.DBSession import filter [as 别名]
def get(cls, name='', seller='', start_date='', end_date='', section=''):
query = DBSession().query(cls)
if name:
query = query.filter(cls.name.like('%{}%'.format(name)))
if seller:
query = query.filter(cls.seller.like('%{}%'.format(seller)))
if section:
query = query.filter(cls.seller.like('%{}%'.format(section)))
if start_date and end_date:
start_date = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date = datetime.datetime.strptime(end_date, '%Y-%m-%d')
query = query.filter(cls.created_at.between(start_date, end_date))
print query
return query.all()