When I try to insert the composite primary key connection returns 0 rows:
CompetitionRound = sa.Table('CompetitionRound', metadata,
sa.Column('CompetitionId', sa.Integer, sa.ForeignKey('Competitions.Id'), primary_key=True),
sa.Column('RoundId', sa.Integer, sa.ForeignKey('Rounds.Id'), primary_key=True))
...
competition_round_insert = await conn.execute(
CompetitionRound.insert()
.values(CompetitionId=competition_id,
RoundId=round_id))
competition_round_row = await competition_round_insert.fetchone()
Seems like it is not possible to insert the composite primary key as values ... but how to insert key in such case ? Unfortunately I have not found some example in SQLAlchemy documentation ... (
From what I understand of the documentation, SQLAlchemy only implicitly returns
autoincrement
primary keys, which composite PKs specifically are not:autoincrement
inserted_primary_key
Meaning you probably want to use an explicit returning clause on your insert. Not that I really see the point though, you obviously have the relevant values since you inserted them.