Verification nom de couche dans DB
This commit is contained in:
parent
e4725c4ece
commit
42f33f619c
@ -525,8 +525,14 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
# Chargement de la couche PostGIS
|
# Chargement de la couche PostGIS
|
||||||
geom_type = 'SELECT right(st_geometrytype(geom),-3) as a FROM ' + schema + '.' + table + ' GROUP BY a'
|
geom_type = 'SELECT right(st_geometrytype(geom),-3) as a FROM ' + schema + '.' + table + ' GROUP BY a'
|
||||||
cur.execute(geom_type)
|
try:
|
||||||
list_typegeom = cur.fetchall()
|
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:
|
if len(list_typegeom) > 1:
|
||||||
for typegeom in list_typegeom:
|
for typegeom in list_typegeom:
|
||||||
if typegeom[0] == 'MultiPolygon':
|
if typegeom[0] == 'MultiPolygon':
|
||||||
@ -547,9 +553,12 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
|
|||||||
# Ajout de la couche au canevas QGIS
|
# Ajout de la couche au canevas QGIS
|
||||||
QgsProject.instance().addMapLayer(layer)
|
QgsProject.instance().addMapLayer(layer)
|
||||||
else:
|
else:
|
||||||
layer = QgsVectorLayer(uri.uri(), table, "postgres")
|
if UndefinedTable:
|
||||||
# Ajout de la couche au canevas QGIS
|
layer = QgsVectorLayer(uri.uri(), table, "postgres")
|
||||||
QgsProject.instance().addMapLayer(layer)
|
# 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:
|
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))
|
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))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user