Correction enumérations
This commit is contained in:
parent
ada3941d44
commit
782320652e
|
@ -1,259 +0,0 @@
|
|||
"""ajout modèles législatives 2024
|
||||
|
||||
Revision ID: 0222cf0ef39b
|
||||
Revises: 99948a33112b
|
||||
Create Date: 2024-06-20 16:34:47.315588
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '0222cf0ef39b'
|
||||
down_revision: Union[str, None] = '99948a33112b'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('legislatives_2024_bloc',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nom', sa.String(length=32), nullable=False),
|
||||
sa.Column('couleur', sa.String(length=7), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('nom')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_france',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_nuance',
|
||||
sa.Column('code', sa.String(length=8), nullable=False),
|
||||
sa.Column('nom', sa.String(length=64), nullable=False),
|
||||
sa.Column('couleur', sa.String(length=7), nullable=False),
|
||||
sa.Column('bloc_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['bloc_id'], ['legislatives_2024_bloc.id'], ),
|
||||
sa.PrimaryKeyConstraint('code'),
|
||||
sa.UniqueConstraint('nom')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_region',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('region_id', sa.String(length=3), nullable=False),
|
||||
sa.Column('resultats_france_id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['region_id'], ['region.code_insee'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_france_id'], ['legislatives_2024_resultats_france.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_departement',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('dpt_id', sa.String(length=3), nullable=False),
|
||||
sa.Column('resultats_region_id', sa.Integer(), nullable=True),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['dpt_id'], ['departement.code_insee'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_region_id'], ['legislatives_2024_resultats_region.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_france',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_france_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_france_id'], ['legislatives_2024_resultats_france.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_region',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_region_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_region_id'], ['legislatives_2024_resultats_region.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_candidat',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('circonscription_id', sa.String(length=6), nullable=False),
|
||||
sa.Column('numero', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('bloc_id', sa.Integer(), nullable=False),
|
||||
sa.Column('nom', sa.String(length=256), nullable=False),
|
||||
sa.Column('prenom', sa.String(length=256), nullable=False),
|
||||
sa.Column('sexe', sa.Enum('MASCULIN', 'FEMININ', name='genre'), nullable=False),
|
||||
sa.Column('date_naissance', sa.Date(), nullable=False),
|
||||
sa.Column('profession', sa.String(length=256), nullable=False),
|
||||
sa.Column('sortant', sa.Boolean(), nullable=False),
|
||||
sa.Column('nom_suppleance', sa.String(length=256), nullable=False),
|
||||
sa.Column('prenom_suppleance', sa.String(length=256), nullable=False),
|
||||
sa.Column('sexe_suppleance', sa.Enum('MASCULIN', 'FEMININ', name='genre'), nullable=False),
|
||||
sa.Column('date_naissance_suppleance', sa.Date(), nullable=False),
|
||||
sa.Column('sortant_suppleance', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['bloc_id'], ['legislatives_2024_bloc.id'], ),
|
||||
sa.ForeignKeyConstraint(['circonscription_id'], ['circonscription.id'], ),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_circonscription',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('circo_id', sa.String(length=6), nullable=False),
|
||||
sa.Column('resultats_departement_id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['circo_id'], ['circonscription.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_departement_id'], ['legislatives_2024_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_commune',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.String(length=5), nullable=False),
|
||||
sa.Column('resultats_dpt_id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['commune.code_insee'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_dpt_id'], ['legislatives_2024_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_departement',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_departement_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_departement_id'], ['legislatives_2024_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_bureau_vote',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('bv_id', sa.String(length=16), nullable=False),
|
||||
sa.Column('resultats_commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('resultats_circo_id', sa.Integer(), nullable=True),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['bv_id'], ['bureau_vote.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_circo_id'], ['legislatives_2024_resultats_circonscription.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_commune_id'], ['legislatives_2024_resultats_commune.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_circonscription',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('candidat_id', sa.Integer(), nullable=False),
|
||||
sa.Column('resultats_circonscription_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['candidat_id'], ['legislatives_2024_candidat.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_circonscription_id'], ['legislatives_2024_resultats_circonscription.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_commune',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_commune_id'], ['legislatives_2024_resultats_commune.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_bureau_vote',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('candidat_id', sa.Integer(), nullable=False),
|
||||
sa.Column('resultats_bureau_vote_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['candidat_id'], ['legislatives_2024_candidat.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_bureau_vote_id'], ['legislatives_2024_resultats_bureau_vote.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('legislatives_2024_voix_bureau_vote')
|
||||
op.drop_table('legislatives_2024_voix_commune')
|
||||
op.drop_table('legislatives_2024_voix_circonscription')
|
||||
op.drop_table('legislatives_2024_resultats_bureau_vote')
|
||||
op.drop_table('legislatives_2024_voix_departement')
|
||||
op.drop_table('legislatives_2024_resultats_commune')
|
||||
op.drop_table('legislatives_2024_resultats_circonscription')
|
||||
op.drop_table('legislatives_2024_candidat')
|
||||
op.drop_table('legislatives_2024_voix_region')
|
||||
op.drop_table('legislatives_2024_voix_france')
|
||||
op.drop_table('legislatives_2024_resultats_departement')
|
||||
op.drop_table('legislatives_2024_resultats_region')
|
||||
op.drop_table('legislatives_2024_nuance')
|
||||
op.drop_table('legislatives_2024_resultats_france')
|
||||
op.drop_table('legislatives_2024_bloc')
|
||||
# ### end Alembic commands ###
|
|
@ -1,8 +1,8 @@
|
|||
"""ajout modèles législatives
|
||||
"""ajout modèles législatives 2022 + 2024
|
||||
|
||||
Revision ID: 99948a33112b
|
||||
Revision ID: 6c0e8136b976
|
||||
Revises: c0443e979a90
|
||||
Create Date: 2024-06-20 12:47:52.732224
|
||||
Create Date: 2024-06-20 16:46:42.696348
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
@ -12,7 +12,7 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '99948a33112b'
|
||||
revision: str = '6c0e8136b976'
|
||||
down_revision: Union[str, None] = 'c0443e979a90'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
@ -43,6 +43,29 @@ def upgrade() -> None:
|
|||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_bloc',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nom', sa.String(length=32), nullable=False),
|
||||
sa.Column('couleur', sa.String(length=7), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('nom')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_france',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2022_nuance',
|
||||
sa.Column('code', sa.String(length=8), nullable=False),
|
||||
sa.Column('nom', sa.String(length=64), nullable=False),
|
||||
|
@ -72,6 +95,35 @@ def upgrade() -> None:
|
|||
sa.ForeignKeyConstraint(['resultats_france_id'], ['legislatives_2022_resultats_france.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_nuance',
|
||||
sa.Column('code', sa.String(length=8), nullable=False),
|
||||
sa.Column('nom', sa.String(length=64), nullable=False),
|
||||
sa.Column('couleur', sa.String(length=7), nullable=False),
|
||||
sa.Column('bloc_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['bloc_id'], ['legislatives_2024_bloc.id'], ),
|
||||
sa.PrimaryKeyConstraint('code'),
|
||||
sa.UniqueConstraint('nom')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_region',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('region_id', sa.String(length=3), nullable=False),
|
||||
sa.Column('resultats_france_id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['region_id'], ['region.code_insee'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_france_id'], ['legislatives_2024_resultats_france.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2022_resultats_departement',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('dpt_id', sa.String(length=3), nullable=False),
|
||||
|
@ -112,6 +164,46 @@ def upgrade() -> None:
|
|||
sa.ForeignKeyConstraint(['resultats_region_id'], ['legislatives_2022_resultats_region.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_departement',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('dpt_id', sa.String(length=3), nullable=False),
|
||||
sa.Column('resultats_region_id', sa.Integer(), nullable=True),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['dpt_id'], ['departement.code_insee'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_region_id'], ['legislatives_2024_resultats_region.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_france',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_france_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_france_id'], ['legislatives_2024_resultats_france.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_region',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_region_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_region_id'], ['legislatives_2024_resultats_region.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2022_candidat',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('circonscription_id', sa.String(length=6), nullable=False),
|
||||
|
@ -184,6 +276,78 @@ def upgrade() -> None:
|
|||
sa.ForeignKeyConstraint(['resultats_departement_id'], ['legislatives_2022_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_candidat',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('circonscription_id', sa.String(length=6), nullable=False),
|
||||
sa.Column('numero', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('bloc_id', sa.Integer(), nullable=False),
|
||||
sa.Column('nom', sa.String(length=256), nullable=False),
|
||||
sa.Column('prenom', sa.String(length=256), nullable=False),
|
||||
sa.Column('sexe', sa.Enum('MASCULIN', 'FEMININ', name='genre'), nullable=False),
|
||||
sa.Column('date_naissance', sa.Date(), nullable=False),
|
||||
sa.Column('profession', sa.String(length=256), nullable=False),
|
||||
sa.Column('sortant', sa.Boolean(), nullable=False),
|
||||
sa.Column('nom_suppleance', sa.String(length=256), nullable=False),
|
||||
sa.Column('prenom_suppleance', sa.String(length=256), nullable=False),
|
||||
sa.Column('sexe_suppleance', sa.Enum('MASCULIN', 'FEMININ', name='genre'), nullable=False),
|
||||
sa.Column('date_naissance_suppleance', sa.Date(), nullable=False),
|
||||
sa.Column('sortant_suppleance', sa.Boolean(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['bloc_id'], ['legislatives_2024_bloc.id'], ),
|
||||
sa.ForeignKeyConstraint(['circonscription_id'], ['circonscription.id'], ),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_circonscription',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('circo_id', sa.String(length=6), nullable=False),
|
||||
sa.Column('resultats_departement_id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['circo_id'], ['circonscription.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_departement_id'], ['legislatives_2024_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_commune',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('commune_id', sa.String(length=5), nullable=False),
|
||||
sa.Column('resultats_dpt_id', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['commune_id'], ['commune.code_insee'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_dpt_id'], ['legislatives_2024_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_departement',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_departement_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_departement_id'], ['legislatives_2024_resultats_departement.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2022_resultats_bureau_vote',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('bv_id', sa.String(length=16), nullable=False),
|
||||
|
@ -226,6 +390,48 @@ def upgrade() -> None:
|
|||
sa.ForeignKeyConstraint(['resultats_commune_id'], ['legislatives_2022_resultats_commune.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_resultats_bureau_vote',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('bv_id', sa.String(length=16), nullable=False),
|
||||
sa.Column('resultats_commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('resultats_circo_id', sa.Integer(), nullable=True),
|
||||
sa.Column('inscrits_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('inscrits_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('votants_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('abstentions_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('exprimes_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('blancs_t2', sa.Integer(), nullable=False),
|
||||
sa.Column('nuls_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['bv_id'], ['bureau_vote.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_circo_id'], ['legislatives_2024_resultats_circonscription.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_commune_id'], ['legislatives_2024_resultats_commune.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_circonscription',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('candidat_id', sa.Integer(), nullable=False),
|
||||
sa.Column('resultats_circonscription_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['candidat_id'], ['legislatives_2024_candidat.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_circonscription_id'], ['legislatives_2024_resultats_circonscription.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_commune',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('nuance_id', sa.String(length=8), nullable=False),
|
||||
sa.Column('resultats_commune_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['nuance_id'], ['legislatives_2024_nuance.code'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_commune_id'], ['legislatives_2024_resultats_commune.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2022_voix_bureau_vote',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('candidat_id', sa.Integer(), nullable=False),
|
||||
|
@ -236,24 +442,49 @@ def upgrade() -> None:
|
|||
sa.ForeignKeyConstraint(['resultats_bureau_vote_id'], ['legislatives_2022_resultats_bureau_vote.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('legislatives_2024_voix_bureau_vote',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('candidat_id', sa.Integer(), nullable=False),
|
||||
sa.Column('resultats_bureau_vote_id', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t1', sa.Integer(), nullable=False),
|
||||
sa.Column('voix_t2', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['candidat_id'], ['legislatives_2024_candidat.id'], ),
|
||||
sa.ForeignKeyConstraint(['resultats_bureau_vote_id'], ['legislatives_2024_resultats_bureau_vote.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('legislatives_2024_voix_bureau_vote')
|
||||
op.drop_table('legislatives_2022_voix_bureau_vote')
|
||||
op.drop_table('legislatives_2024_voix_commune')
|
||||
op.drop_table('legislatives_2024_voix_circonscription')
|
||||
op.drop_table('legislatives_2024_resultats_bureau_vote')
|
||||
op.drop_table('legislatives_2022_voix_commune')
|
||||
op.drop_table('legislatives_2022_voix_circonscription')
|
||||
op.drop_table('legislatives_2022_resultats_bureau_vote')
|
||||
op.drop_table('legislatives_2024_voix_departement')
|
||||
op.drop_table('legislatives_2024_resultats_commune')
|
||||
op.drop_table('legislatives_2024_resultats_circonscription')
|
||||
op.drop_table('legislatives_2024_candidat')
|
||||
op.drop_table('legislatives_2022_voix_departement')
|
||||
op.drop_table('legislatives_2022_resultats_commune')
|
||||
op.drop_table('legislatives_2022_resultats_circonscription')
|
||||
op.drop_table('legislatives_2022_candidat')
|
||||
op.drop_table('legislatives_2024_voix_region')
|
||||
op.drop_table('legislatives_2024_voix_france')
|
||||
op.drop_table('legislatives_2024_resultats_departement')
|
||||
op.drop_table('legislatives_2022_voix_region')
|
||||
op.drop_table('legislatives_2022_voix_france')
|
||||
op.drop_table('legislatives_2022_resultats_departement')
|
||||
op.drop_table('legislatives_2024_resultats_region')
|
||||
op.drop_table('legislatives_2024_nuance')
|
||||
op.drop_table('legislatives_2022_resultats_region')
|
||||
op.drop_table('legislatives_2022_nuance')
|
||||
op.drop_table('legislatives_2024_resultats_france')
|
||||
op.drop_table('legislatives_2024_bloc')
|
||||
op.drop_table('legislatives_2022_resultats_france')
|
||||
op.drop_table('legislatives_2022_bloc')
|
||||
# ### end Alembic commands ###
|
|
@ -1,5 +1,23 @@
|
|||
import enum
|
||||
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
class Genre(enum.Enum):
|
||||
MASCULIN = "M"
|
||||
FEMININ = "F"
|
||||
|
||||
|
||||
class Personnalite(enum.Enum):
|
||||
DEFAUT = ""
|
||||
EURODEPUTE = "RPE"
|
||||
DEPUTE = "DEP"
|
||||
SENATEUR = "SEN"
|
||||
MINISTRE = "MIN"
|
||||
PRESIDENT_CONSEIL_REGIONAL = "PCR"
|
||||
PRESIDENT_CONSEIL_DEPARTEMENTAL = "PCD"
|
||||
MAIRE = "MAI"
|
||||
|
|
|
@ -6,6 +6,7 @@ from sqlalchemy import Boolean, Date, Enum, ForeignKey, Integer, String
|
|||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
|
||||
from nupes.models import Base, Region, Departement, Commune
|
||||
from nupes.models.base import Genre, Personnalite
|
||||
|
||||
|
||||
class BlocEuropeennes2024(Base):
|
||||
|
@ -59,20 +60,6 @@ class ListeEuropeennes2024(Base):
|
|||
|
||||
|
||||
class CandidatEuropeennes2024(Base):
|
||||
class Genre(enum.Enum):
|
||||
MASCULIN = "M"
|
||||
FEMININ = "F"
|
||||
|
||||
class Personnalite(enum.Enum):
|
||||
DEFAUT = ""
|
||||
EURODEPUTE = "RPE"
|
||||
DEPUTE = "DEP"
|
||||
SENATEUR = "SEN"
|
||||
MINISTRE = "MIN"
|
||||
PRESIDENT_CONSEIL_REGIONAL = "PCR"
|
||||
PRESIDENT_CONSEIL_DEPARTEMENTAL = "PCD"
|
||||
MAIRE = "MAI"
|
||||
|
||||
__tablename__ = "europeennes_2024_candidat"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
|
|
|
@ -6,6 +6,7 @@ from sqlalchemy import Boolean, Date, Enum, ForeignKey, Integer, String
|
|||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
|
||||
from nupes.models import Base, Region, Departement, Commune, Circonscription
|
||||
from nupes.models.base import Genre
|
||||
|
||||
|
||||
class BlocLegislatives2022(Base):
|
||||
|
@ -46,10 +47,6 @@ class NuanceLegislatives2022(Base):
|
|||
|
||||
|
||||
class CandidatLegislatives2022(Base):
|
||||
class Genre(enum.Enum):
|
||||
MASCULIN = "M"
|
||||
FEMININ = "F"
|
||||
|
||||
__tablename__ = "legislatives_2022_candidat"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
|
|
|
@ -5,7 +5,7 @@ from typing import List
|
|||
from sqlalchemy import Boolean, Date, Enum, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
|
||||
from nupes.models import Base, Region, Departement, Commune, Circonscription
|
||||
from nupes.models import Base, Region, Departement, Commune, Circonscription, Genre
|
||||
|
||||
|
||||
class BlocLegislatives2024(Base):
|
||||
|
@ -46,10 +46,6 @@ class NuanceLegislatives2024(Base):
|
|||
|
||||
|
||||
class CandidatLegislatives2024(Base):
|
||||
class Genre(enum.Enum):
|
||||
MASCULIN = "M"
|
||||
FEMININ = "F"
|
||||
|
||||
__tablename__ = "legislatives_2024_candidat"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
|
|
|
@ -5,6 +5,7 @@ from sqlalchemy import Engine, select
|
|||
from sqlalchemy.orm import Session
|
||||
|
||||
from nupes.cache import get_file
|
||||
from nupes.models import Genre, Personnalite
|
||||
from nupes.models.europeennes2024 import BlocEuropeennes2024, NuanceEuropeennes2024, ListeEuropeennes2024, \
|
||||
CandidatEuropeennes2024
|
||||
|
||||
|
@ -148,10 +149,10 @@ def importer_candidats(engine: Engine, verbose: bool = False) -> None:
|
|||
candidat.liste_id = liste.id
|
||||
candidat.nom = line['Nom sur le bulletin de vote']
|
||||
candidat.prenom = line['Prénom sur le bulletin de vote']
|
||||
candidat.sexe = CandidatEuropeennes2024.Genre(line['Sexe'])
|
||||
candidat.sexe = Genre(line['Sexe'])
|
||||
candidat.date_naissance = datetime.datetime.strptime(line['Date de naissance'], "%d/%m/%Y").date()
|
||||
candidat.profession = line['Profession']
|
||||
candidat.code_personnalite = CandidatEuropeennes2024.Personnalite(line['Code personnalité'])
|
||||
candidat.code_personnalite = Personnalite(line['Code personnalité'])
|
||||
candidat.sortant = line['Sortant'] == "OUI"
|
||||
else:
|
||||
candidat = CandidatEuropeennes2024(
|
||||
|
@ -159,10 +160,10 @@ def importer_candidats(engine: Engine, verbose: bool = False) -> None:
|
|||
ordre=int(line['Ordre']),
|
||||
nom=line['Nom sur le bulletin de vote'],
|
||||
prenom=line['Prénom sur le bulletin de vote'],
|
||||
sexe=CandidatEuropeennes2024.Genre(line['Sexe']).name,
|
||||
sexe=Genre(line['Sexe']).name,
|
||||
date_naissance=datetime.datetime.strptime(line['Date de naissance'], "%d/%m/%Y").date(),
|
||||
profession=line['Profession'],
|
||||
code_personnalite=CandidatEuropeennes2024.Personnalite(line['Code personnalité']).name,
|
||||
code_personnalite=Personnalite(line['Code personnalité']).name,
|
||||
sortant=line['Sortant'] == "OUI",
|
||||
)
|
||||
session.add(candidat)
|
||||
|
|
|
@ -6,6 +6,7 @@ from sqlalchemy.orm import Session
|
|||
from tqdm import tqdm
|
||||
|
||||
from nupes.cache import get_file
|
||||
from nupes.models import Genre
|
||||
from nupes.models.legislatives2022 import BlocLegislatives2022, NuanceLegislatives2022, CandidatLegislatives2022
|
||||
|
||||
|
||||
|
@ -128,13 +129,13 @@ def importer_candidats(engine: Engine, verbose: bool = False) -> None:
|
|||
bloc_id=nuance.bloc_id,
|
||||
nom=line['Nom candidat'],
|
||||
prenom=line['Prénom candidat'],
|
||||
sexe=CandidatLegislatives2022.Genre(line['Sexe candidat']).name,
|
||||
sexe=Genre(line['Sexe candidat']).name,
|
||||
date_naissance=datetime.datetime.strptime(line['Date naissance candidat'], "%d/%m/%Y").date(),
|
||||
profession=line['Profession candidat'],
|
||||
sortant=line['Le candidat est sortant'] == "Oui",
|
||||
nom_suppleance=line['Nom remplaçant'],
|
||||
prenom_suppleance=line['Prénom remplaçant'],
|
||||
sexe_suppleance=CandidatLegislatives2022.Genre(line['Sexe remplaçant']).name,
|
||||
sexe_suppleance=Genre(line['Sexe remplaçant']).name,
|
||||
date_naissance_suppleance=datetime.datetime.strptime(line['Date naiss. remplaçant'],
|
||||
"%d/%m/%Y").date(),
|
||||
sortant_suppleance=line['Le remplaçant est sortant'] == "Oui",
|
||||
|
|
|
@ -6,6 +6,7 @@ from sqlalchemy.orm import Session
|
|||
from tqdm import tqdm
|
||||
|
||||
from nupes.cache import get_file
|
||||
from nupes.models import Genre
|
||||
from nupes.models.legislatives2024 import BlocLegislatives2024, NuanceLegislatives2024, CandidatLegislatives2024
|
||||
|
||||
|
||||
|
@ -116,14 +117,14 @@ def importer_candidats(engine: Engine, verbose: bool = False) -> None:
|
|||
candidat.bloc_id = nuance.bloc_id
|
||||
candidat.nom = line['Nom du candidat']
|
||||
candidat.prenom = line['Prénom du candidat']
|
||||
candidat.sexe = CandidatLegislatives2024.Genre(line['Sexe du candidat'])
|
||||
candidat.sexe = Genre(line['Sexe du candidat'])
|
||||
candidat.date_naissance = datetime.datetime.strptime(line['Date de naissance du candidat'],
|
||||
"%d/%m/%Y").date()
|
||||
candidat.profession = line['Profession']
|
||||
candidat.sortant = line['Sortant'] == "OUI"
|
||||
candidat.nom_suppleance = line['Nom remplaçant']
|
||||
candidat.prenom_suppleance = line['Prénom remplaçant']
|
||||
candidat.sexe_suppleance = CandidatLegislatives2024.Genre(line['Sexe remplaçant'])
|
||||
candidat.sexe_suppleance = Genre(line['Sexe remplaçant'])
|
||||
candidat.date_naissance_suppleance = datetime.datetime.strptime(
|
||||
line['Date de naissance remplaçant'], "%d/%m/%Y").date()
|
||||
candidat.sortant = line['Sortant remplaçant'] == "OUI"
|
||||
|
@ -135,14 +136,14 @@ def importer_candidats(engine: Engine, verbose: bool = False) -> None:
|
|||
bloc_id=nuance.bloc_id,
|
||||
nom=line['Nom du candidat'],
|
||||
prenom=line['Prénom du candidat'],
|
||||
sexe=CandidatLegislatives2024.Genre(line['Sexe du candidat']).name,
|
||||
sexe=Genre(line['Sexe du candidat']).name,
|
||||
date_naissance=datetime.datetime.strptime(line['Date de naissance du candidat'],
|
||||
"%d/%m/%Y").date(),
|
||||
profession=line['Profession'],
|
||||
sortant=line['Sortant'] == "OUI",
|
||||
nom_suppleance=line['Nom remplaçant'],
|
||||
prenom_suppleance=line['Prénom remplaçant'],
|
||||
sexe_suppleance=CandidatLegislatives2024.Genre(line['Sexe remplaçant']).name,
|
||||
sexe_suppleance=Genre(line['Sexe remplaçant']).name,
|
||||
date_naissance_suppleance=datetime.datetime.strptime(line['Date de naissance remplaçant'],
|
||||
"%d/%m/%Y").date(),
|
||||
sortant_suppleance=line['Sortant remplaçant'] == "OUI",
|
||||
|
|
Loading…
Reference in New Issue