File size: 2,140 Bytes
180a7cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import sqlite3
import csv

db = sqlite3.connect("futurisys.db")
cursor = db.cursor()

# Supprimer l'ancienne table si elle existe
cursor.execute("DROP TABLE IF EXISTS employes;")

# Créer la table avec EXACTEMENT les colonnes du CSV
cursor.execute("""
CREATE TABLE employes (
    employee_id INTEGER,
    age INTEGER,
    revenu_mensuel FLOAT,
    statut_marital TEXT,
    departement TEXT,
    poste TEXT,
    annee_experience_totale INTEGER,
    annees_dans_l_entreprise INTEGER,
    annees_dans_le_poste_actuel INTEGER,
    satisfaction_employee_environnement INTEGER,
    note_evaluation_precedente FLOAT,
    satisfaction_employee_nature_travail INTEGER,
    satisfaction_employee_equipe INTEGER,
    satisfaction_employee_equilibre_pro_perso INTEGER,
    note_evaluation_actuelle FLOAT,
    heure_supplementaires TEXT,
    augementation_salaire_precedente FLOAT,
    nombre_participation_pee INTEGER,
    frequence_deplacement TEXT,
    annes_sous_responsable_actuel INTEGER
);
""")

# Charger le CSV
with open("employes.csv", newline='', encoding="utf-8") as f:
    reader = csv.DictReader(f)
    rows = [(
        row["employee_id"],
        row["age"],
        row["revenu_mensuel"],
        row["statut_marital"],
        row["departement"],
        row["poste"],
        row["annee_experience_totale"],
        row["annees_dans_l_entreprise"],
        row["annees_dans_le_poste_actuel"],
        row["satisfaction_employee_environnement"],
        row["note_evaluation_precedente"],
        row["satisfaction_employee_nature_travail"],
        row["satisfaction_employee_equipe"],
        row["satisfaction_employee_equilibre_pro_perso"],
        row["note_evaluation_actuelle"],
        row["heure_supplementaires"],
        row["augementation_salaire_precedente"],
        row["nombre_participation_pee"],
        row["frequence_deplacement"],
        row["annes_sous_responsable_actuel"]
    ) for row in reader]

# Insérer les données
cursor.executemany("""
INSERT INTO employes VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
""", rows)

db.commit()
db.close()

print("🎉 Import terminé à 100 % avec 20 colonnes !")