Bonjour à tous,


Je vous sollicite ce soir car je n'arrive pas à trouver mon erreur. Je souhaite importer en masse dans SqLite pour cela j'utilise le code ci-dessous :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
injectionBdd(data_filename, db_filename):
    """
    Fonction injectant les data dans la bdd
    """
    SQL = """
    insert into modbus (NomFichier, ModbusNum, DateHeure, Cheure, \
                        U12min, U12max, U12moy, \
                        U23min, U23max, U23moy, \
                        U31min, U31max, U31moy, \
                        V1min, V1max, V1moy, \
                        V2min, V2max, V2moy, \
                        V3min, V3max, V3moy, \
                        FREQmin, FREQmax, FREQmoy, \
                        I1min, I1max, I1moy, \
                        I2min, I2max, I2moy, \
                        I3min, I3max, I3moy, \
                        Inmin, Inmax, Inmoy, \
                        PACTmin, PACTmax, PACTmoy, \
                        PREAmin, PREAmax, PREAmoy, \
                        PAPPmin, PAPPmax, PAPPmoy, \
                        COSmin, COSmax, COSmoy, \
                        PACT1min, PACT1max, PACT1moy, \
                        PACT2min, PACT2max, PACT2moy, \
                        PACT3min, PACT3max, PACT3moy, \
                        PREA1min, PREA1max, PREA1moy, \
                        PREA2min, PREA2max, PREA2moy, \
                        PREA3min, PREA3max, PREA3moy, \
                        PAPP1min, PAPP1max, PAPP1moy, \
                        PAPP2min, PAPP2max, PAPP2moy, \
                        PAPP3min, PAPP3max, PAPP3moy, \
                        COS1min, COS1max, COS1moy, \
                        COS2min, COS2max, COS2moy, \
                        COS3min, COS3max, COS3moy)
    values (:NomFichier, :ModbusNum, :DateHeure, :Cheure, \
                        :U12min, :U12max, :U12moy, \
                        :U23min, :U23max, :U23moy, \
                        :U31min, :U31max, :U31moy, \
                        :V1min, :V1max, :V1moy, \
                        :V2min, :V2max, :V2moy, \
                        :V3min, :V3max, :V3moy, \
                        :FREQmin, :FREQmax, :FREQmoy, \
                        :I1min, :I1max, :I1moy, \
                        :I2min, :I2max, :I2moy, \
                        :I3min, :I3max, :I3moy, \
                        :Inmin, :Inmax, :Inmoy, \
                        :PACTmin, :PACTmax, :PACTmoy, \
                        :PREAmin, :PREAmax, :PREAmoy, \
                        :PAPPmin, :PAPPmax, :PAPPmoy, \
                        :COSmin, :COSmax, :COSmoy, \
                        :PACT1min, :PACT1max, :PACT1moy, \
                        :PACT2min, :PACT2max, :PACT2moy, \
                        :PACT3min, :PACT3max, :PACT3moy, \
                        :PREA1min, :PREA1max, :PREA1moy, \
                        :PREA2min, :PREA2max, :PREA2moy, \
                        :PREA3min, :PREA3max, :PREA3moy, \
                        :PAPP1min, :PAPP1max, :PAPP1moy, \
                        :PAPP2min, :PAPP2max, :PAPP2moy, \
                        :PAPP3min, :PAPP3max, :PAPP3moy, \
                        :COS1min, :COS1max, :COS1moy, \
                        :COS2min, :COS2max, :COS2moy, \
                        :COS3min, :COS3max, :COS3moy)
         """
    with open(data_filename, 'rt') as csv_file:
        csv_reader = csv.DictReader(csv_file, delimiter=';')
        with sqlite3.connect(db_filename) as conn:
            cursor = conn.cursor()
            cursor.executemany(SQL, csv_reader)
        cursor.close()
        conn.close()
et lorsque je lance mon script j'ai le message suivant :
Traceback (most recent call last):
File "D:\ENERGETIQUE\SCRIPTS\modbusCSV2sqlite_test.py", line 132, in <module>
injectionBdd(repTemp+'modbus.csv' , repDBmodbus)
File "D:\ENERGETIQUE\SCRIPTS\modbusCSV2sqlite_test.py", line 111, in injectionBdd
cursor.executemany(SQL, csv_reader)
ProgrammingError: You did not supply a value for binding 83.
alors que j'ai bien mis la valeur pour le binding 83 puisqu'il s'agit de
:COS3min
Merci de votre aide