I have the following table:
class Schedule(Base):
__tablename__ = "schedule_"
__table_args__ = ({"schema": BELGARATH, "extend_existing": True})
id_ = Column(Integer, primary_key=True)
tour_id = Column(Integer, index=True)
tournament_id = Column(Integer, index=True)
round_id = Column(Integer, index=True)
player_id_p1 = Column(Integer, index=True)
player_id_p2 = Column(Integer, index=True)
p1_win = Column(Float)
Which I am trying to update with the following query:
update_schedule = dal.session.query(
Schedule.tour_id,
Schedule.tournament_id,
Schedule.round_id,
Schedule.player_id_p1,
Schedule.player_id_p2,
Schedule.p1_win,
)
update_schedule = update_schedule.filter(
Schedule.tour_id == prediction["tour_id"],
Schedule.tournament_id == prediction["tournament_id"],
Schedule.round_id == prediction["round_id"],
Schedule.player_id_p1 == prediction["player_id_p1"],
Schedule.player_id_p2 == prediction["player_id_p2"],
)
update_schedule.p1_win = prediction["p1_win"]
breakpoint()
dal.session.commit()
Where prediction is the following dictionary:
{'tour_id': 0, 'tournament_id': 1, 'round_id': 1, 'player_id_p1': 1, 'player_id_p2': 2, 'p1_win': 2.0}
The change isn't being applied to the database and I can't work out why.
If at the breakpoint I run:
update_schedule.p1_win
Then I get the result as 2.0. However, if I look at update_schedule then this shows (0, 1, 1, 1, 2, None) and the p1_win change doesn't get applied to the database after the commit. What am I missing?