当前位置: 首页>>代码示例>>Python>>正文


Python DBSession.filter方法代码示例

本文整理汇总了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()
开发者ID:csammis,项目名称:reef,代码行数:13,代码来源:EventManager.py

示例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()
开发者ID:csammis,项目名称:reef,代码行数:15,代码来源:EventManager.py

示例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()
开发者ID:JASON0916,项目名称:ebela,代码行数:16,代码来源:EbayProduct.py


注:本文中的models.DBSession.filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。