from sqlalchemy import literal
query = db_session.query(AlarmRule.id, literal(‘value‘).label(‘num‘)).filter(AlarmRule.id==1).first()
query.num
u‘value‘
为查询结果增加了一个num字段,且值一直为value
2023-11-11 14:19:40
from sqlalchemy import literal
query = db_session.query(AlarmRule.id, literal(‘value‘).label(‘num‘)).filter(AlarmRule.id==1).first()
query.num
u‘value‘
为查询结果增加了一个num字段,且值一直为value