給出以下模型定義:
class User(Base): ... birthday = Column(Date, index=True) # Ex. '1987-01-17' in the database ...
query = DBSession.query(User).filter( User.birthday.between('1985-01-17', '1988-01-17') )
給出以下模型定義:
# Filter by upper bound date query = DBSession.query(User).filter(User.birthday <= '1988-01-17') # Filter by lower bound date query = DBSession.query(User).filter(User.birthday >= '1985-01-17') # Filter by equality query = DBSession.query(User).filter(User.birthday == '1987-01-17')
以上是如何使用日期欄位按年齡範圍過濾 SQLAlchemy 使用者?的詳細內容。更多資訊請關注PHP中文網其他相關文章!