4

我如何将这样的东西翻译成 SQLAlchemy?

select x - y as difference...

我知道该怎么做:

x.label('foo')

...但我不确定将“.label()”方法调用放在下面的位置:

select ([table.c.x - table.c.y], ...
4

1 回答 1

9

ColumnElement方法只是一个帮手;label()可以通过以下方式使用:

select([sql.expression.label('foo', table.c.x - table.c.y), ...])
于 2008-12-16T06:52:24.643 回答