Вопрос

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