extremely helpful, like a beacon for a lost ship:) thanks
On Friday, December 11, 2020 at 5:59:50 AM UTC-8 Simon King wrote:
> I think this page might explain it:
>
>
> https://docs.sqlalchemy.org/en/13/core/sqlelement.html#column-elements-and-expressions
>
> The "case" function, like many other
I think this page might explain it:
https://docs.sqlalchemy.org/en/13/core/sqlelement.html#column-elements-and-expressions
The "case" function, like many other SQLAlchemy functions, returns an
instance of a ClauseElement subclass. This instance is used later when
building SQL queries. Columns
Thanks. One thing to clarify, I noticed that here you used `case` without
using in a context of `select`. Is this considered a shorthand within
sqlalchemy?
On Fri, Dec 11, 2020 at 2:16 AM Simon King wrote:
> You can do it, but you need to use an SQL conditional rather than a
> python one. In
You can do it, but you need to use an SQL conditional rather than a
python one. In this case that would probably be a CASE expression:
https://docs.sqlalchemy.org/en/13/core/sqlelement.html#sqlalchemy.sql.expression.case
I think it would look something like this:
from sqlalchemy.sql import case
I have a mapped class:
class Model(sqlalchemy.declarative_base()):
attr_a = Column(String)
attr_b = Column(Integer)
attr_c = Column(Integer)
aggr = column_property(attr_b + attr_c IF attr_a=='go' ELSE attr_b -
attr_c)
Last line is pseoudo code that requires some conditional