Boolean field query with sqlalchemy

故事扮演 提交于 2019-12-10 13:32:33

问题


Postgres model:

class Song(db.Model):
    id3_parsed = db.Column(db.Boolean, server_default=u'false')

Running the following query gives the correct count:

select count(*) from song where id3_parsed is false;

But how do I do it with flask-sqlalchemy? This doesn't work:

songs = Song.query.filter(Song.id3_parsed == False).all()

回答1:


songs = Song.query.filter(Song.id3_parsed.is_(False)).all()


来源:https://stackoverflow.com/questions/31811119/boolean-field-query-with-sqlalchemy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!