SQLALchemy如何查詢mysql某個區間內的數據


查了下,找到3種方式:

方法一注意時間格式:xxxx-xx-xx

方法二沒有‘day’

方法三的時間格式同方法一

1、result = Jobs.query.filter(Jobs.create_time < '2017-07-10').all()
2、result = Jobs.query.filter(and_(
    extract('year', Jobs.create_time) == 2017,
    extract('month', Jobs.create_time) == 7
                                )).all()
3、result = Jobs.query.filter(Jobs.create_time.between('1990-01-01', '2018-01-01'))

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM