diff --git a/CenRa_FLUX/flux_editor.py b/CenRa_FLUX/flux_editor.py index 53e9847..1e09678 100644 --- a/CenRa_FLUX/flux_editor.py +++ b/CenRa_FLUX/flux_editor.py @@ -525,8 +525,14 @@ class Flux_Editor(QDialog, EDITOR_CLASS): # Chargement de la couche PostGIS geom_type = 'SELECT right(st_geometrytype(geom),-3) as a FROM ' + schema + '.' + table + ' GROUP BY a' - cur.execute(geom_type) - list_typegeom = cur.fetchall() + try: + cur.execute(geom_type) + list_typegeom = cur.fetchall() + UndefinedTable = True + except psycopg2.errors.UndefinedTable: + print("Error table name") + list_typegeom = '' + UndefinedTable = False if len(list_typegeom) > 1: for typegeom in list_typegeom: if typegeom[0] == 'MultiPolygon': @@ -547,9 +553,12 @@ class Flux_Editor(QDialog, EDITOR_CLASS): # Ajout de la couche au canevas QGIS QgsProject.instance().addMapLayer(layer) else: - layer = QgsVectorLayer(uri.uri(), table, "postgres") - # Ajout de la couche au canevas QGIS - QgsProject.instance().addMapLayer(layer) + if UndefinedTable: + layer = QgsVectorLayer(uri.uri(), table, "postgres") + # Ajout de la couche au canevas QGIS + QgsProject.instance().addMapLayer(layer) + else: + self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» semble ne pas avoir le même nom dans la BD, merci de contacter votre administrateur pour régler le problème !", QMessageBox.StandardButton(0x00004000)) else: self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» ne ce trouve pas dans cette BD !", QMessageBox.StandardButton(0x00004000))