__tablename__ = "money_managements_results"
strategies = relationship(
"Strategy",
secondary="strategy_mm_result",
back_populates="mm_results"
)
class Strategy(Base):
__tablename__ = "strategies"
mm_results = relationship(
"MoneyManagementsResult",
secondary="strategy_mm_result",
back_populates="strategies"
)
class StrategyMMResult(Base):
__tablename__ = "strategy_mm_result"
strategy_id = Column(Integer, ForeignKey("strategies.id"), primary_key=True)
mm_result_id = Column(Integer, ForeignKey("money_managements_results.id"), primary_key=True)
Хочу в созданный money_management_result в strategies добавить strategy
money_management_result = MoneyManagementsResult(...)
session.add(money_management_result)
session.commit()
money_management_result.strategies.append(strategy)
session.commit()
но получаю ошибку
sqlalchemy.orm.exc.ObjectDeletedError: Instance '<MoneyManagementsResult at 0x7fd05cb3bd10>' has been deleted, or its row is otherwise not present.
куда копать?
я же, вроде, правильно создаю `money_management_result`🤔
Обсуждают сегодня