我无法弄清楚如何在查询中进行“大于或等于”比较。
我有一个模型字段:
invoicedate = db.Column(db.Date(), nullable=True, key='InvoiceDate')
我正在尝试执行以下过滤器:
Invoice.query.filter_by(invoicedate >= date.today()).count()
当我运行 View 时,它不断抛出以下错误:
NameError: global name 'invoicedate' is not defined
sqlalchemy 或flask-sqlalchemy 中大于或等于过滤器的正确语法是什么?
最佳答案
你要filter
,不是 filter_by
:
Invoice.query.filter(Invoice.invoicedate >= date.today())
见 this answer更多关于
filter
对比 filter_by
关于sqlalchemy - Flask-SQLAlchemy - 大于或等于,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19699756/