mirror of
https://forgemia.inra.fr/theophile.terraz/acoused.git
synced 2026-10-30 03:10:40 +01:00
A context menu is added. Update Table for Save action created.
This commit is contained in:
1 parent
4d8000993d
commit
825b5aa9bb
3 files changed
+427
-296
No files matched your search
@@ -0,0 +1,89 @@
|
||||
import numpy as np
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication
|
||||
import sqlite3
|
||||
import settings as stg
|
||||
from os import chdir, getcwd
|
||||
import time
|
||||
|
||||
|
||||
class UpdateTableForSave:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
start = time.time()
|
||||
chdir(stg.dirname_save_as)
|
||||
print("get cwd for save :", getcwd())
|
||||
print("stg.filename_save_as ", stg.filename_save_as)
|
||||
self.update_table()
|
||||
print(f"end : {time.time() - start} sec")
|
||||
|
||||
def update_table(self):
|
||||
|
||||
# Create a new database and open a database connection to allow sqlite3 to work with it.
|
||||
cnx = sqlite3.connect(stg.filename_save_as + '.acd')
|
||||
|
||||
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
||||
cur = cnx.cursor()
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# --- Table BSRawData_i ---
|
||||
start_table_BSRawData = time.time()
|
||||
|
||||
# # --- Fill table BSRawData_i with data stg.depth_reshape ---
|
||||
#
|
||||
# for i in stg.acoustic_data:
|
||||
# exec("query1 = '''ALTER TABLE BSRawData ADD COLUMN BS_cross_section BLOB''' ")
|
||||
#
|
||||
# exec("cur.execute(query1)")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# for i in stg.acoustic_data:
|
||||
# cur.execute(f"''' UPDATE BSRawData SET BS_cross_section = " + str(stg.BS_cross_section[i].tobytes()) + " WHERE acoustic_data =" + str(i) + " ''' ")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# print(f"end : {time.time() - start_table_BSRawData} sec")
|
||||
|
||||
if stg.BS_cross_section:
|
||||
|
||||
cur.execute(''' DROP TABLE BSRawData ''')
|
||||
print(f"end : {time.time() - start_table_BSRawData} sec")
|
||||
|
||||
cur.execute('''CREATE TABLE BSRawData(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
time BLOB,
|
||||
time_cross_section BLOB,
|
||||
depth BLOB,
|
||||
depth_cross_section BLOB,
|
||||
BS_raw_data BLOB,
|
||||
BS_cross_section BLOB)''')
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
|
||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, time_cross_section,
|
||||
depth, depth_cross_section,
|
||||
BS_raw_data, BS_cross_section)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.time[i].tobytes(), stg.time_cross_section[i].tobytes(),
|
||||
stg.depth[i].tobytes(), stg.depth_cross_section[i].tobytes(),
|
||||
stg.BS_raw_data[i].tobytes(), stg.BS_cross_section[i].tobytes()))
|
||||
|
||||
cnx.commit()
|
||||
|
||||
if stg.depth_bottom:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
# Close database cursor
|
||||
cur.close()
|
||||
|
||||
# Close database connection
|
||||
cnx.close()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user