carl carl - 7 months ago 8
SQL Question

adding a null column to s selection in sqlalchemy

Hi is is possible to get a null column in sqlalchemy? For example I would like to select all user ids together with a NULL column

db.session.query(models.User.id, NULL)


The reason for this is that I need to do a UNION, which requires the same number of columns...
thanks
fl

rmn rmn
Answer

You can use sqlalchemy.sql.expression.null

from sqlalchemy.sql.expression import null
db.session.query(models.User.id, null())
Comments