请帮助我完成将原始查询转换为特定于SqlAlchemy的任务,并使用标签或别名将列作为Bool进行比较。
我无法弄清楚如何使用label从原始SQL查询中获取与 AS 相同的功能:
来自SQL的:public class NicePeople {
public string VNP_Name {set;get;}
public int VNP_Age {set;get;}
public float VNP_Score {set;get;}
}
到SqlAlchemy:currentMeeting.id > 0 as current
在我的回复
中获取一个名为当前的新列原始SQL:
(current_meeting.c.id > 0).label('current')
SqlAlchemy查询(我得到的结果没有所需的额外列当前):
SELECT meeting.*, currentMeeting.id > 0 as current \
FROM meeting \
LEFT JOIN( \
SELECT * \
FROM meeting \
WHERE meeting_date > now() \
ORDER BY meeting_date asc limit 1) currentMeeting \
ON currentMeeting.id = meeting.id \
WHERE meeting.id = {0}".format(meeting_id)