From 8c1ee420806bd1eae1be5f993add3873bee37889 Mon Sep 17 00:00:00 2001 From: tlaveille Date: Thu, 12 Feb 2026 11:05:14 +0100 Subject: [PATCH] kill des connection postgresql --- CenRa_FLUX/flux_editor.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/CenRa_FLUX/flux_editor.py b/CenRa_FLUX/flux_editor.py index 15ca444..ea465e6 100644 --- a/CenRa_FLUX/flux_editor.py +++ b/CenRa_FLUX/flux_editor.py @@ -204,6 +204,12 @@ class Flux_Editor(QDialog, EDITOR_CLASS): if dbtype == sigdb: cur.execute(SQLAddFav) con.commit() + else: + conSIG = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + sigdb + " user=" + user + " password=" + mdp) + curSIG = conSIG.cursor(cursor_factory=psycopg2.extras.DictCursor) + curSIG.execute(SQLAddFav) + conSIG.commit() + conSIG.close() else: FAV = "mStarIconAdd.png" @@ -212,6 +218,12 @@ class Flux_Editor(QDialog, EDITOR_CLASS): if dbtype == sigdb: cur.execute(SQLDelFav) con.commit() + else: + conSIG = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + sigdb + " user=" + user + " password=" + mdp) + curSIG = conSIG.cursor(cursor_factory=psycopg2.extras.DictCursor) + curSIG.execute(SQLDelFav) + conSIG.commit() + conSIG.close() iconFav = QIcon() iconFav.addPixmap(QtGui.QPixmap(resources_path('icons', FAV)), QIcon.Mode(0), QIcon.State(1)) @@ -220,6 +232,8 @@ class Flux_Editor(QDialog, EDITOR_CLASS): self.FavButton.clicked.connect(self.AddOrDelToUserFav) def initialisation_flux(self): + if self.toolButton_2.text() == "1": + self.filtre_favorit(None) self.tableWidget.clear() if NoSignals == 0: if dbtype == sigdb: @@ -277,15 +291,20 @@ class Flux_Editor(QDialog, EDITOR_CLASS): for grandsFind in list_grands: GrandUser.append(grandsFind[0]) - if dbtype == sigdb: - SQLFavTable = "SELECT concat(schema_name, '.', table_name) FROM admin_sig.favtable WHERE utilisateur LIKE '" + user + "';" + SQLFavTable = "SELECT concat(schema_name, '.', table_name) FROM admin_sig.favtable WHERE utilisateur LIKE '" + user + "';" + if dbtype == refdb: + conSIG = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + sigdb + " user=" + user + " password=" + mdp) + curSIG = conSIG.cursor(cursor_factory=psycopg2.extras.DictCursor) + curSIG.execute(SQLFavTable) + list_fav = curSIG.fetchall() + conSIG.close() + print('SIG') + else: cur.execute(SQLFavTable) list_fav = cur.fetchall() - FavList = [] - for favFind in list_fav: - FavList.append(favFind[0]) - else: - FavList = [] + FavList = [] + for favFind in list_fav: + FavList.append(favFind[0]) self.tableWidget.setRowCount(len(list_schema)) self.tableWidget.setColumnCount(5) @@ -330,8 +349,6 @@ class Flux_Editor(QDialog, EDITOR_CLASS): iconFav.addPixmap(QtGui.QPixmap(resources_path('icons', FAV)), QIcon.Mode(0), QIcon.State(1)) self.FavButton = QPushButton(iconFav, "") self.FavButton.clicked.connect(self.AddOrDelToUserFav) - if dbtype == refdb: - self.FavButton.setEnabled(False) if (str(value[0]) + '.' + str(value[1])) in RasterList: SVG = 'mIconRaster.svg'