假设:
class Users(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String)
我怎么能在sqlalchemy中这样做:
select id,username,0 as deleted from users
其中deleted
不在users
。
答案 0 :(得分:0)
您可以使用sqlalchemy.sql.expression.literal
from sqlalchemy.sql.expression import literal
db.session.query(User.id, User.username, literal(0).label('deleted'))