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
hey there -
that query is not a cartesian product. the child and child_parent tables are
linked together in the WHERE clause. I would assume the query here is in fact
taking about half a second to run, the problem here is in the composition of
Python objects for every row.
I am assuming
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
Dear sqlalchemy users,
After look at the docs I arrived at the following structure:
```
Base = declarative_base()
parent_child = Table(
"parent_child",
Base.metadata,
Column("parent_id", Integer, ForeignKey("parent.id")),
Column("child_id", Integer, ForeignKey("child.id")),
)
class
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