Correction clés étrangères

This commit is contained in:
2024-06-09 23:53:25 +02:00
parent 828becbd4e
commit 58ffe8a46a
4 changed files with 12 additions and 8 deletions

View File

@ -149,8 +149,12 @@ def importer_resultats_departements(engine: Engine, debug: bool = False) -> None
resultats_departement.nuls = resultats["nuls"]
resultats_departement.exprimes = resultats["exprimes"]
else:
resultats_region = session.execute(select(ResultatsRegion).filter_by(region_id=reg_code)) \
.scalar_one_or_none()
resultats_departement = ResultatsDepartement(
dpt_id=dpt_code,
resultats_region_id=resultats_region.id if resultats_region else None,
inscrits=resultats["inscrits"],
abstentions=resultats["abstentions"],
votants=resultats["votants"],