Fix save method on existing file #16.
parent
b26d8a2906
commit
17619f15ac
|
|
@ -104,42 +104,72 @@ class UpdateTableForSave:
|
|||
# Drop Table if exists
|
||||
cur.execute("DROP TABLE if exists Measure")
|
||||
|
||||
cur.execute("""CREATE TABLE Measure(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
Date STRING,
|
||||
Hour STRING,
|
||||
frequency FLOAT,
|
||||
sound_attenuation FLOAT,
|
||||
kt_read FLOAT,
|
||||
kt_corrected FLOAT,
|
||||
NbProfiles FLOAT,
|
||||
NbProfilesPerSeconds FLOAT,
|
||||
NbCells FLOAT,
|
||||
CellSize FLOAT,
|
||||
PulseLength FLOAT,
|
||||
NbPingsPerSeconds FLOAT,
|
||||
NbPingsAveragedPerProfile FLOAT,
|
||||
GainRx FLOAT,
|
||||
GainTx FLOAT
|
||||
)
|
||||
""")
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE Measure(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
Date STRING,
|
||||
Hour STRING,
|
||||
frequency FLOAT,
|
||||
sound_attenuation FLOAT,
|
||||
kt_read FLOAT,
|
||||
kt_corrected FLOAT,
|
||||
NbProfiles FLOAT,
|
||||
NbProfilesPerSeconds FLOAT,
|
||||
NbCells FLOAT,
|
||||
CellSize FLOAT,
|
||||
PulseLength FLOAT,
|
||||
NbPingsPerSeconds FLOAT,
|
||||
NbPingsAveragedPerProfile FLOAT,
|
||||
GainRx FLOAT,
|
||||
GainTx FLOAT
|
||||
)"""
|
||||
)
|
||||
|
||||
# Fill the table Measure
|
||||
for i in stg.acoustic_data:
|
||||
|
||||
for j in range(stg.freq[i].shape[0]):
|
||||
cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
|
||||
NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
||||
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx,
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
|
||||
stg.nb_profiles[i][j], stg.nb_profiles_per_sec[i][j], stg.nb_cells[i][j],
|
||||
stg.cell_size[i][j], stg.pulse_length[i][j], stg.nb_pings_per_sec[i][j],
|
||||
stg.nb_pings_averaged_per_profile[i][j], stg.gain_rx[i][j], stg.gain_tx[i][j],
|
||||
str(stg.date[i].year) + str('-') + str(stg.date[i].month) + str('-') + str(stg.date[i].day),
|
||||
str(stg.hour[i].hour) + str(':') + str(stg.hour[i].minute)
|
||||
))
|
||||
cur.execute(
|
||||
'''
|
||||
INSERT into Measure(
|
||||
acoustic_data,
|
||||
Date, Hour,
|
||||
frequency,
|
||||
sound_attenuation,
|
||||
kt_read, kt_corrected,
|
||||
NbProfiles, NbProfilesPerSeconds,
|
||||
NbCells, CellSize,
|
||||
PulseLength,
|
||||
NbPingsPerSeconds,
|
||||
NbPingsAveragedPerProfile,
|
||||
GainRx, GainTx
|
||||
) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(
|
||||
stg.acoustic_data[i],
|
||||
(
|
||||
str(stg.date[i].year) + str('-') +
|
||||
str(stg.date[i].month) + str('-') +
|
||||
str(stg.date[i].day)
|
||||
),
|
||||
(
|
||||
str(stg.hour[i].hour) + str(':') +
|
||||
str(stg.hour[i].minute)
|
||||
),
|
||||
stg.freq[i][j],
|
||||
stg.water_attenuation[i][j],
|
||||
stg.kt_read[j],
|
||||
stg.kt_corrected[j],
|
||||
stg.nb_profiles[i][j],
|
||||
stg.nb_profiles_per_sec[i][j],
|
||||
stg.nb_cells[i][j],
|
||||
stg.cell_size[i][j],
|
||||
stg.pulse_length[i][j],
|
||||
stg.nb_pings_per_sec[i][j],
|
||||
stg.nb_pings_averaged_per_profile[i][j],
|
||||
stg.gain_rx[i][j], stg.gain_tx[i][j]
|
||||
)
|
||||
)
|
||||
|
||||
# Commit the transaction after executing INSERT.
|
||||
cnx.commit()
|
||||
|
|
|
|||
Loading…
Reference in New Issue