from sqlalchemy.orm import validates


class Obs(DeclarativeBase):
    __tablename__ = 'obs'
id = Column(Integer, primary_key=True)
state = Column(Integer, default=0)

@validates('state')
def update_state(self, key, value):
    self.task.state = value
return value
Trigger in sqlachemy