SQLAlchemy: Hybrid Expression With Relationship (on Parent)
Similar to question SQLAlchemy: Hybrid expression with relationship but I would like to know what is the best method to implement hybrid expresions on the parent. The adapted examp
Solution 1:
from sqlalchemy import select, func
@n_teachers.expression
def n_teachers(self):
return select([func.count(Teacher.id)]).where(Teacher.id_school == self.id).as_scalar()
Post a Comment for "SQLAlchemy: Hybrid Expression With Relationship (on Parent)"