代码如下:
# 基于Flask的SQLAlchemy # models class History(db.Model): __tablename__ = 'historys' id = db.Column(db.Integer, primary_key=True) date= db.Column(db.Date)
from sqlalchemy import extract, and_ historys = History.query.filter(_and(extract('year', History.date) == 2016, extract('month', History.date) == 12).all()
参考:
http://blog.csdn.net/yannanxiu/article/details/53816567