实际上,除了错字之外,您的查询是正确的:您的过滤器排除了所有记录:您应该更改
<=for
>=,反之亦然:
qry = DBSession.query(User).filter( and_(User.birthday <= '1988-01-17', User.birthday >= '1985-01-17'))# or same:qry = DBSession.query(User).filter(User.birthday <= '1988-01-17'). filter(User.birthday >= '1985-01-17')
您也可以使用
between:
qry = DBSession.query(User).filter(User.birthday.between('1985-01-17', '1988-01-17'))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)