Skip to content
Snippets Groups Projects
Commit d274fcaf authored by Lan Dam's avatar Lan Dam
Browse files

channel_dialog.py: get_data_list(): modify select query to have default values...

channel_dialog.py: get_data_list(): modify select query to have default values when null; get_row_inputs() fix typo during PEP8; update_data(): add missing comma in update query
parent 5deee141
No related branches found
No related tags found
1 merge request!70DB config dialogs
......@@ -77,12 +77,15 @@ class ChannelDialog(UiDBInfoDialog):
Get list of data to fill self.data_table_widgets' content
"""
channel_rows = execute_db(
f"SELECT channel, label, param, convertFactor, unit, fixPoint "
f"SELECT channel, "
f"IFNULL(label, '') AS label,"
f" IFNULL(param, '') AS param,"
f" convertFactor,"
f" IFNULL(unit, '') AS unit,"
f" IFNULL(fixPoint, 0) AS fixPoint "
f"FROM Channels "
f"WHERE dataType='{self.data_type}'")
return [[d[0], d[1], d[2], d[3],
'' if d[4] is None else d[4],
d[5]]
return [[d[0], d[1], d[2], float(d[3]), d[4], int(d[5])]
for d in channel_rows]
def get_row_inputs(self, row_idx):
......@@ -107,7 +110,7 @@ class ChannelDialog(UiDBInfoDialog):
:param remove_row_idx: index of row to be removed
"""
self.data_table_widget.remove_row(remove_row_idx)
self.data_table_widget.removeRow(remove_row_idx)
for i in range(remove_row_idx, self.data_table_widget.rowCount()):
cell_widget = self.data_table_widget.cellWidget(i, 0)
cell_widget.setText(str(i))
......@@ -127,7 +130,7 @@ class ChannelDialog(UiDBInfoDialog):
f" {row[3]}, '{row[4]}', {row[5]}, '{self.data_type}')")
update_sql = (f"UPDATE Channels SET channel='{row[0]}', "
f"label='{row[1]}', param='{row[2]}', "
f"convertFactor={row[3]}, unit='{row[4]}' "
f"convertFactor={row[3]}, unit='{row[4]}', "
f"fixPoint={row[5]} "
f"WHERE channel='%s'"
f" AND dataType='{self.data_type}'")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment