flake8 postgis
This commit is contained in:
parent
133e785568
commit
7df08ae02a
@ -4,9 +4,9 @@ __email__ = "info@3liz.org"
|
||||
|
||||
|
||||
from qgis.core import QgsApplication
|
||||
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
||||
from qgis.PyQt.QtCore import QUrl
|
||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
||||
from qgis.PyQt.QtWidgets import QAction
|
||||
from qgis.utils import iface
|
||||
import qgis
|
||||
|
||||
@ -15,8 +15,10 @@ import qgis
|
||||
|
||||
import socket
|
||||
import os
|
||||
from qgis.PyQt.QtCore import QSettings
|
||||
from .about_form import AboutDialog
|
||||
from .tools.resources import (
|
||||
plugin_path,
|
||||
# plugin_path,
|
||||
pyperclip,
|
||||
resources_path,
|
||||
maj_verif,
|
||||
@ -26,13 +28,11 @@ pyperclip()
|
||||
from .postgis_editor import Postgis_Editor
|
||||
from .postgis_creator import Postgis_Creator
|
||||
from .postgis_rename import Postgis_Rename
|
||||
from .about_form import AboutDialog
|
||||
|
||||
from qgis.PyQt.QtCore import *
|
||||
|
||||
|
||||
IPAddr = socket.gethostbyname(socket.gethostname())
|
||||
|
||||
|
||||
class PgPostgis:
|
||||
def __init__(self):
|
||||
""" Constructor. """
|
||||
@ -121,6 +121,7 @@ class PgPostgis:
|
||||
"""
|
||||
dialog = AboutDialog(iface)
|
||||
dialog.exec()
|
||||
|
||||
def open_help():
|
||||
""" Open the online help. """
|
||||
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
||||
|
||||
@ -2,50 +2,50 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
# Import the PyQt and QGIS libraries
|
||||
from builtins import next
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import qgis
|
||||
# from builtins import next
|
||||
# from builtins import str
|
||||
# from builtins import object
|
||||
# import qgis
|
||||
from qgis.PyQt.QtCore import QSettings
|
||||
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog,QMessageBox
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox
|
||||
# from qgis.PyQt.QtGui import QIcon
|
||||
|
||||
from qgis.PyQt.QtCore import *
|
||||
from qgis.PyQt.QtGui import *
|
||||
# from qgis.PyQt.QtCore import *
|
||||
# from qgis.PyQt.QtGui import *
|
||||
from qgis.PyQt import QtGui
|
||||
|
||||
from qgis.core import *
|
||||
from qgis.core import QgsDataSourceUri
|
||||
# from qgis.core import *
|
||||
from qgis.core import QgsSettings
|
||||
|
||||
try:
|
||||
from .tools.PythonSQL import login_base
|
||||
except:
|
||||
except ValueError:
|
||||
print('Pas de fichier PythonSQL')
|
||||
|
||||
from .tools.SQLRequet import *
|
||||
# from .tools.SQLRequet import *
|
||||
|
||||
from .tools.resources import (
|
||||
load_ui,
|
||||
resources_path,
|
||||
send_issues,
|
||||
# send_issues,
|
||||
create_vierge,
|
||||
create_contour,
|
||||
create_travaux,
|
||||
create_habita
|
||||
)
|
||||
from .issues import CenRa_Issues
|
||||
# from .issues import CenRa_Issues
|
||||
|
||||
from qgis.utils import iface
|
||||
import os.path
|
||||
import webbrowser, os
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
import base64
|
||||
# import os.path
|
||||
# import webbrowser, os
|
||||
# import psycopg2
|
||||
# import psycopg2.extras
|
||||
# import base64
|
||||
|
||||
EDITOR_CLASS = load_ui('CenRa_Postgis_base.ui')
|
||||
|
||||
class Postgis_Creator(QDialog, EDITOR_CLASS):
|
||||
|
||||
class Postgis_Creator(QDialog, EDITOR_CLASS):
|
||||
def __init__(self, parent=None):
|
||||
_ = parent
|
||||
super().__init__()
|
||||
@ -64,14 +64,14 @@ class Postgis_Creator(QDialog, EDITOR_CLASS):
|
||||
result = self.exec()
|
||||
# See if OK was pressed
|
||||
if result == 1:
|
||||
|
||||
# **********************************Debut_script****************************************
|
||||
|
||||
### Creation du schema pour le nouveau site
|
||||
# Creation du schema pour le nouveau site
|
||||
if self.at.isChecked():
|
||||
schema = "_" + self.dept.currentText() + "_at_" + self.nom.text().lower() # Ajout de "_" pour eviter pb de numero en premier caractere
|
||||
# Ajout de "_" pour eviter pb de numero en premier caractere
|
||||
schema = "_" + self.dept.currentText() + "_at_" + self.nom.text().lower()
|
||||
else:
|
||||
schema = "_" + self.dept.currentText() + "_" + self.nom.text().lower() # Ajout de "_" pour eviter pb de numero en premier caractere
|
||||
# Ajout de "_" pour eviter pb de numero en premier caractere
|
||||
schema = "_" + self.dept.currentText() + "_" + self.nom.text().lower()
|
||||
|
||||
if self.nom.text() == "" or self.nom.text() == "NULL":
|
||||
QMessageBox.warning(None, "Oups :", "Veuillez renseigner un nom de dossier.")
|
||||
@ -98,13 +98,12 @@ class Postgis_Creator(QDialog, EDITOR_CLASS):
|
||||
cur.execute(SQL_schema)
|
||||
cur.execute(SQL_GRANT_SCHEMA)
|
||||
else:
|
||||
iface.messageBar().pushMessage("POSTGRESQL :", "Pas de couche sélectionnée, création refusée.", level=Qgis.Warning, duration=30)
|
||||
iface.messageBar().pushMessage("POSTGRESQL :", "Pas de couche sélectionnée, création refusée.", level=1, duration=30)
|
||||
|
||||
create_contour(self, schema, cur, con, host, port, dbname, user, mdp)
|
||||
create_habita(self, schema, cur, con, host, port, dbname, user, mdp)
|
||||
create_travaux(self, schema, cur, con, host, port, dbname, user, mdp)
|
||||
create_vierge(self, schema, cur, con, host, port, dbname, user, mdp)
|
||||
|
||||
|
||||
con.close()
|
||||
pass
|
||||
@ -4,47 +4,45 @@ from __future__ import absolute_import
|
||||
# Import the PyQt and QGIS libraries
|
||||
from builtins import next
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import qgis
|
||||
# from builtins import object
|
||||
# import qgis
|
||||
from qgis.PyQt.QtCore import QSettings
|
||||
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox
|
||||
# from qgis.PyQt.QtGui import QIcon
|
||||
|
||||
from qgis.PyQt.QtCore import *
|
||||
from qgis.PyQt.QtGui import *
|
||||
from qgis.PyQt import QtGui
|
||||
|
||||
from qgis.core import *
|
||||
from qgis.core import QgsDataSourceUri
|
||||
# from qgis.core import *
|
||||
from qgis.core import QgsSettings
|
||||
|
||||
try:
|
||||
from .tools.PythonSQL import login_base
|
||||
except:
|
||||
except ValueError:
|
||||
print('Pas de fichier PythonSQL')
|
||||
from .tools.SQLRequet import *
|
||||
# from .tools.SQLRequet import *
|
||||
|
||||
from .tools.resources import (
|
||||
load_ui,
|
||||
resources_path,
|
||||
send_issues,
|
||||
# send_issues,
|
||||
create_vierge,
|
||||
create_contour,
|
||||
create_travaux,
|
||||
create_habita
|
||||
)
|
||||
from .issues import CenRa_Issues
|
||||
# from .issues import CenRa_Issues
|
||||
|
||||
import os.path
|
||||
import webbrowser, os
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
import base64
|
||||
# import os.path
|
||||
# import webbrowser
|
||||
# import psycopg2
|
||||
# import psycopg2.extras
|
||||
# import base64
|
||||
from qgis.utils import iface
|
||||
|
||||
EDITOR_CLASS = load_ui('CenRa_PostgisTable_base.ui')
|
||||
|
||||
class Postgis_Editor(QDialog, EDITOR_CLASS):
|
||||
|
||||
class Postgis_Editor(QDialog, EDITOR_CLASS):
|
||||
def __init__(self, parent=None):
|
||||
_ = parent
|
||||
super().__init__()
|
||||
@ -54,7 +52,7 @@ class Postgis_Editor(QDialog, EDITOR_CLASS):
|
||||
self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
|
||||
self.iface = iface
|
||||
|
||||
### Outil Ajout de nouvelles couche a un dossier
|
||||
# Outil Ajout de nouvelles couche a un dossier
|
||||
def raise_(self):
|
||||
self.activateWindow()
|
||||
account = login_base("account")
|
||||
@ -71,7 +69,6 @@ class Postgis_Editor(QDialog, EDITOR_CLASS):
|
||||
where schemaname ~ E'^_(0|1|2|3|4|6|7|f)'
|
||||
group by schemaname
|
||||
order by schemaname)
|
||||
|
||||
select string_agg(schemaname,',')
|
||||
from list_schema
|
||||
group by "group";"""
|
||||
@ -86,7 +83,8 @@ class Postgis_Editor(QDialog, EDITOR_CLASS):
|
||||
|
||||
self.schema.clear()
|
||||
self.schema.addItems(listItems)
|
||||
self.schema.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier schema
|
||||
# Pour ne pas commencer la liste au premier schema
|
||||
self.schema.setCurrentIndex(-1)
|
||||
|
||||
# show the dialog
|
||||
self.show()
|
||||
|
||||
@ -2,43 +2,39 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
# Import the PyQt and QGIS libraries
|
||||
from builtins import next
|
||||
# from builtins import next
|
||||
from builtins import str
|
||||
from builtins import object
|
||||
import qgis
|
||||
# from builtins import object
|
||||
# import qgis
|
||||
from qgis.PyQt.QtCore import QSettings
|
||||
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog, QMessageBox,QDialogButtonBox
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.PyQt.QtWidgets import QDialog, QMessageBox, QDialogButtonBox
|
||||
# from qgis.PyQt.QtGui import QIcon
|
||||
|
||||
from qgis.PyQt.QtCore import *
|
||||
from qgis.PyQt.QtGui import *
|
||||
# from qgis.PyQt.QtCore import *
|
||||
# from qgis.PyQt.QtGui import *
|
||||
from qgis.PyQt import QtGui
|
||||
|
||||
from qgis.core import *
|
||||
from qgis.core import QgsDataSourceUri
|
||||
# from qgis.core import *
|
||||
from qgis.core import QgsSettings, QgsDataSourceUri, QgsProject
|
||||
|
||||
try:
|
||||
from .tools.PythonSQL import login_base
|
||||
except:
|
||||
except ValueError:
|
||||
print('Pas de fichier PythonSQL')
|
||||
from .tools.SQLRequet import *
|
||||
# from .tools.SQLRequet import *
|
||||
|
||||
from .tools.resources import (
|
||||
load_ui,
|
||||
resources_path,
|
||||
send_issues,
|
||||
create_vierge,
|
||||
create_contour,
|
||||
create_travaux,
|
||||
create_habita
|
||||
# send_issues,
|
||||
)
|
||||
from .issues import CenRa_Issues
|
||||
# from .issues import CenRa_Issues
|
||||
|
||||
import os.path
|
||||
import webbrowser, os
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
import base64
|
||||
# import os.path
|
||||
# import webbrowser
|
||||
# import psycopg2
|
||||
# import psycopg2.extras
|
||||
# import base64
|
||||
from qgis.utils import iface
|
||||
|
||||
EDITOR_CLASS = load_ui('CenRa_PostgisRename_base.ui')
|
||||
@ -52,10 +48,11 @@ try:
|
||||
dbname = account[4]
|
||||
cur = account[7]
|
||||
con = account[8]
|
||||
except:
|
||||
except ValueError:
|
||||
print('')
|
||||
class Postgis_Rename(QDialog, EDITOR_CLASS):
|
||||
|
||||
|
||||
class Postgis_Rename(QDialog, EDITOR_CLASS):
|
||||
def __init__(self, parent=None):
|
||||
_ = parent
|
||||
super().__init__()
|
||||
@ -67,7 +64,8 @@ class Postgis_Rename(QDialog, EDITOR_CLASS):
|
||||
|
||||
self.schema.currentIndexChanged.connect(self.Test)
|
||||
self.buttonBox.accepted.connect(self.msgBox)
|
||||
### Outil Ajout de nouvelles couche a un dossier
|
||||
# Outil Ajout de nouvelles couche a un dossier
|
||||
|
||||
def raise_(self):
|
||||
self.activateWindow()
|
||||
self.groupBox_3.hide()
|
||||
@ -188,12 +186,10 @@ class Postgis_Rename(QDialog, EDITOR_CLASS):
|
||||
SQL_RENAME_SCHEMA = 'ALTER SCHEMA ' + oldSchemaName + ' RENAME TO ' + newSchemaName
|
||||
allSQLrun = allSQLrun + SQL_RENAME_SCHEMA
|
||||
cur.execute(SQL_RENAME_SCHEMA)
|
||||
#print(allSQLrun)
|
||||
con.commit()
|
||||
for LayerOpen in allTableList:
|
||||
self.UnloadLoadLayers(LayerOpen[0], LayerOpen[1], LayerOpen[2])
|
||||
|
||||
|
||||
def UnloadLoadLayers(self, OldName, NewSchema, NewTable):
|
||||
allLayers = (QgsProject.instance().mapLayers().values())
|
||||
listLayers = []
|
||||
@ -210,7 +206,7 @@ class Postgis_Rename(QDialog, EDITOR_CLASS):
|
||||
host = QgsDataSourceUri(provider.dataSourceUri()).host()
|
||||
port = QgsDataSourceUri(provider.dataSourceUri()).port()
|
||||
|
||||
### Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
import configparser
|
||||
import shutil
|
||||
import tempfile
|
||||
import base64
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
# import base64
|
||||
# import psycopg2
|
||||
# import psycopg2.extras
|
||||
import os
|
||||
from os.path import abspath, join, pardir, dirname
|
||||
from qgis.core import QgsDataSourceUri
|
||||
from .SQLRequet import *
|
||||
from .SQLRequet import geom, champ_contour, champ_travaux_prevus_multilinestring, champ_travaux_prevus_point, champ_travaux_prevus_multipolygon, champ_vegethab_multipolygon, champ_vegethab_multilinestring, champ_vegethab_point, champ_viergeLigne, champ_viergePoint, champ_viergePolygone
|
||||
from qgis.PyQt import uic
|
||||
|
||||
__copyright__ = "Copyright 2019, 3Liz"
|
||||
@ -109,46 +109,51 @@ def load_ui(*args):
|
||||
|
||||
return ui_class
|
||||
|
||||
|
||||
def pyperclip():
|
||||
dst = dirname(dirname(__file__)) + "\\tools\\"
|
||||
if os.access('N:/', os.R_OK):
|
||||
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
|
||||
try:
|
||||
shutil.copy(src, dst)
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
print('404')
|
||||
except UnboundLocalError:
|
||||
print('404')
|
||||
|
||||
|
||||
def send_issues(url, titre, body, labels):
|
||||
import requests
|
||||
import urllib.request
|
||||
import json
|
||||
import os
|
||||
import qgis
|
||||
# import os
|
||||
# import qgis
|
||||
|
||||
usr = os.environ['USERNAME']
|
||||
# usr = os.environ['USERNAME']
|
||||
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
|
||||
url = url + '?token=' + token
|
||||
|
||||
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
|
||||
|
||||
|
||||
payload = {'title': titre, 'body': body, 'labels': labels}
|
||||
try:
|
||||
urllib.request.urlopen('https://google.com')
|
||||
binar = True
|
||||
except:
|
||||
except ValueError:
|
||||
binar = False
|
||||
r = ''
|
||||
if binar:
|
||||
r = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||
return r
|
||||
|
||||
|
||||
def maj_verif(NAME):
|
||||
import qgis
|
||||
import urllib.request
|
||||
iface = qgis.utils.iface
|
||||
from qgis.core import Qgis
|
||||
|
||||
url = qgis.utils.pluginMetadata(NAME,'repository')
|
||||
# url = qgis.utils.pluginMetadata(NAME, 'repository')
|
||||
# URL = url+'/raw/branch/main/plugins.xml'
|
||||
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
|
||||
# print(URL)
|
||||
@ -157,7 +162,7 @@ def maj_verif(NAME):
|
||||
try:
|
||||
urllib.request.urlopen('https://google.com')
|
||||
binar = True
|
||||
except:
|
||||
except urllib.error.URLError:
|
||||
binar = False
|
||||
if binar:
|
||||
try:
|
||||
@ -167,20 +172,23 @@ def maj_verif(NAME):
|
||||
version_plugin = version_web[valeur_version_web:valeur_version_web + len_version]
|
||||
if version_plugin != version:
|
||||
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
|
||||
except:
|
||||
except urllib.error.URLError:
|
||||
print("error gitea version ssl")
|
||||
else:
|
||||
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
|
||||
|
||||
|
||||
def devlog(NAME):
|
||||
import qgis
|
||||
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
|
||||
devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
|
||||
return devmaj
|
||||
|
||||
|
||||
def create_contour(self, schema, cur, con, host, port, dbname, user, mdp):
|
||||
### Creation de la table contour
|
||||
if self.couche_contour.isChecked(): # Verifie si la checkbox est cochee
|
||||
# Creation de la table contour
|
||||
# Verifie si la checkbox est cochee
|
||||
if self.couche_contour.isChecked():
|
||||
if self.annee_1.text() == 'aaaa' or self.annee_1.text() == '':
|
||||
tablename = schema + "_contour"
|
||||
else:
|
||||
@ -211,21 +219,24 @@ def create_contour(self,schema,cur,con,host ,port ,dbname ,user ,mdp):
|
||||
cur.execute(SQL_trigger_area_ha)
|
||||
cur.execute(SQL_trigger_date_creation)
|
||||
cur.execute(SQL_trigger_date_maj)
|
||||
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
# Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
cur.execute(SQL_style)
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
|
||||
## Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
|
||||
def create_travaux(self, schema, cur, con, host, port, dbname, user, mdp):
|
||||
### Creation de la table travaux prevus
|
||||
# Creation de la table travaux prevus
|
||||
if self.couche_travaux_prevus.isChecked():
|
||||
# **********Poly
|
||||
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
|
||||
@ -241,7 +252,6 @@ def create_travaux(self,schema,cur,con,host,port,dbname,user,mdp):
|
||||
cur.execute(RETURNE)
|
||||
sequence_name = cur.fetchone()[0]
|
||||
|
||||
|
||||
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
|
||||
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
|
||||
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
|
||||
@ -259,19 +269,20 @@ def create_travaux(self,schema,cur,con,host,port,dbname,user,mdp):
|
||||
cur.execute(SQL_trigger_date_maj)
|
||||
cur.execute(SQL_trigger_area_m2)
|
||||
cur.execute(SQL_trigger_area_ha)
|
||||
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
# Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
cur.execute(SQL_style)
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
|
||||
## Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
# **********ligne
|
||||
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
|
||||
@ -304,19 +315,20 @@ def create_travaux(self,schema,cur,con,host,port,dbname,user,mdp):
|
||||
cur.execute(SQL_trigger_date_maj)
|
||||
cur.execute(SQL_trigger_length_m)
|
||||
cur.execute(SQL_trigger_length_km)
|
||||
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
# Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
cur.execute(SQL_style)
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
|
||||
## Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
# **********point
|
||||
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
|
||||
@ -347,22 +359,24 @@ def create_travaux(self,schema,cur,con,host,port,dbname,user,mdp):
|
||||
cur.execute(SQL_trigger_date_creation)
|
||||
cur.execute(SQL_trigger_date_maj)
|
||||
cur.execute(SQL_trigger_coordonnees)
|
||||
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
# Enregistrement du style (comme style par defaut) dans la table layer_styles
|
||||
cur.execute(SQL_style)
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
|
||||
## Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
|
||||
def create_habita(self, schema, cur, con, host, port, dbname, user, mdp):
|
||||
### Creation de la table habitat
|
||||
# Creation de la table habitat
|
||||
if self.couche_habitat.isChecked():
|
||||
if self.annee_2.text() == 'aaaa' or self.annee_2.text() == '':
|
||||
tablename = schema + "_habitat"
|
||||
@ -395,14 +409,14 @@ def create_habita(self,schema,cur,con,host ,port ,dbname ,user ,mdp):
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
### Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename_1, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
tablename_2 = tablename + "_lignes"
|
||||
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename_2 + "','gid')"
|
||||
@ -429,14 +443,14 @@ def create_habita(self,schema,cur,con,host ,port ,dbname ,user ,mdp):
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
### Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename_2, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
tablename_3 = tablename + "_polygones"
|
||||
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename_3 + "','gid')"
|
||||
@ -463,16 +477,18 @@ def create_habita(self,schema,cur,con,host ,port ,dbname ,user ,mdp):
|
||||
cur.execute(SQL_GRANT_TABLE)
|
||||
|
||||
con.commit()
|
||||
### Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename_3, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
|
||||
def create_vierge(self, schema, cur, con, host, port, dbname, user, mdp):
|
||||
### Creation de la table vierge
|
||||
# Creation de la table vierge
|
||||
if self.couche_vierge.isChecked():
|
||||
if self.annee_4.text() == 'aaaa' or self.annee_4.text() == '':
|
||||
tablename = schema + "_" + self.nom_couche_vierge.text().lower()
|
||||
@ -521,11 +537,11 @@ def create_vierge(self,schema,cur,con,host ,port ,dbname ,user ,mdp):
|
||||
|
||||
con.commit()
|
||||
|
||||
### Affichage de la table
|
||||
# Affichage de la table
|
||||
uri = QgsDataSourceUri()
|
||||
# set host name, port, database name, username and password
|
||||
uri.setConnection(host, port, dbname, user, mdp)
|
||||
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
|
||||
uri.setDataSource(schema, tablename, geom)
|
||||
|
||||
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user