문제

I'm using peewee in my Flask application and I have one column in a table which can be null:

somecolumn = ForeignKeyField(Something, related_name='messages', null = True, default=None)

I now want to select all records in which somecolumn is not null/None/Empty. I tried to do this with the following:

Message.select().where(Message.somecolumn != None)
Message.select().where(Message.somecolumn != '')

Unfortunately, neither works. Does anybody know how I can do this? All tips are welcome!

도움이 되었습니까?

해결책

I'm not a peewee expert, but from the documentation (Querying) it looks like you need:

Message.select().where(Message.somecolumn >> None)

다른 팁

It's a possibility:

Message.select().where(Message.somecolumn.is_null(False))

Documentation

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top