Pregunta

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!

¿Fue útil?

Solución

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

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

Otros consejos

It's a possibility:

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

Documentation

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top