Fix save method on existing file #16.
parent
b26d8a2906
commit
17619f15ac
|
|
@ -104,7 +104,10 @@ class UpdateTableForSave:
|
||||||
# Drop Table if exists
|
# Drop Table if exists
|
||||||
cur.execute("DROP TABLE if exists Measure")
|
cur.execute("DROP TABLE if exists Measure")
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE Measure(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute(
|
||||||
|
"""
|
||||||
|
CREATE TABLE Measure(
|
||||||
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
Date STRING,
|
Date STRING,
|
||||||
Hour STRING,
|
Hour STRING,
|
||||||
|
|
@ -121,25 +124,52 @@ class UpdateTableForSave:
|
||||||
NbPingsAveragedPerProfile FLOAT,
|
NbPingsAveragedPerProfile FLOAT,
|
||||||
GainRx FLOAT,
|
GainRx FLOAT,
|
||||||
GainTx FLOAT
|
GainTx FLOAT
|
||||||
|
)"""
|
||||||
)
|
)
|
||||||
""")
|
|
||||||
|
|
||||||
# Fill the table Measure
|
# Fill the table Measure
|
||||||
for i in stg.acoustic_data:
|
for i in stg.acoustic_data:
|
||||||
|
|
||||||
for j in range(stg.freq[i].shape[0]):
|
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,
|
cur.execute(
|
||||||
NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
'''
|
||||||
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx,
|
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]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
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)
|
|
||||||
))
|
|
||||||
|
|
||||||
# Commit the transaction after executing INSERT.
|
# Commit the transaction after executing INSERT.
|
||||||
cnx.commit()
|
cnx.commit()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue