mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[processing] move spatialite and postgis utils into tools package
This commit is contained in:
parent
6e1302047c
commit
57b16187e6
@ -35,8 +35,7 @@ from processing.core.parameters import ParameterVector
|
||||
from processing.core.parameters import ParameterString
|
||||
from processing.core.parameters import ParameterSelection
|
||||
from processing.core.parameters import ParameterTableField
|
||||
from processing.tools import dataobjects
|
||||
from processing.algs.qgis import postgis_utils
|
||||
from processing.tools import dataobjects, postgis
|
||||
|
||||
|
||||
class ImportIntoPostGIS(GeoAlgorithm):
|
||||
@ -117,9 +116,9 @@ class ImportIntoPostGIS(GeoAlgorithm):
|
||||
providerName = 'postgres'
|
||||
|
||||
try:
|
||||
db = postgis_utils.GeoDB(host=host, port=port, dbname=database,
|
||||
db = postgis.GeoDB(host=host, port=port, dbname=database,
|
||||
user=username, passwd=password)
|
||||
except postgis_utils.DbError as e:
|
||||
except postgis.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
self.tr("Couldn't connect to database:\n%s") % unicode(e))
|
||||
|
||||
|
@ -30,7 +30,7 @@ from qgis.PyQt.QtCore import QSettings
|
||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||
from processing.core.parameters import ParameterString
|
||||
from processing.algs.qgis import postgis_utils
|
||||
from processing.tools import postgis
|
||||
|
||||
|
||||
class PostGISExecuteSQL(GeoAlgorithm):
|
||||
@ -58,15 +58,15 @@ class PostGISExecuteSQL(GeoAlgorithm):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
self.tr('Wrong database connection name: %s' % connection))
|
||||
try:
|
||||
self.db = postgis_utils.GeoDB(host=host, port=port,
|
||||
self.db = postgis.GeoDB(host=host, port=port,
|
||||
dbname=database, user=username, passwd=password)
|
||||
except postgis_utils.DbError as e:
|
||||
except postgis.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
self.tr("Couldn't connect to database:\n%s") % unicode(e))
|
||||
|
||||
sql = self.getParameterValue(self.SQL).replace('\n', ' ')
|
||||
try:
|
||||
self.db._exec_sql_and_commit(unicode(sql))
|
||||
except postgis_utils.DbError as e:
|
||||
except postgis.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
self.tr('Error executing SQL:\n%s') % unicode(e))
|
||||
|
@ -31,8 +31,8 @@ from qgis.PyQt.QtCore import QSettings
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.PyQt.QtWidgets import QTreeWidgetItem, QMessageBox
|
||||
from qgis.PyQt import uic
|
||||
from processing.algs.qgis.postgis_utils import GeoDB
|
||||
from qgis.core import QgsDataSourceURI, QgsCredentials
|
||||
from processing.tools.postgis import GeoDB
|
||||
|
||||
pluginPath = os.path.split(os.path.dirname(__file__))[0]
|
||||
WIDGET, BASE = uic.loadUiType(
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
postgis_utils.py
|
||||
postgis.py
|
||||
---------------------
|
||||
Date : November 2012
|
||||
Copyright : (C) 2012 by Martin Dobias
|
@ -2,7 +2,7 @@
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
spatialite_utils.py
|
||||
spatialite.py
|
||||
---------------------
|
||||
Date : November 2015
|
||||
Copyright : (C) 2015 by René-Luc Dhont
|
@ -16,8 +16,6 @@
|
||||
* *
|
||||
***************************************************************************
|
||||
"""
|
||||
from processing.algs.qgis import postgis_utils
|
||||
from processing.algs.qgis import spatialite_utils
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'February 2013'
|
||||
@ -43,7 +41,7 @@ from qgis.core import (QGis, QgsFields, QgsField, QgsGeometry, QgsRectangle,
|
||||
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||
from processing.tools import dataobjects
|
||||
from processing.tools import dataobjects, spatialite, postgis
|
||||
|
||||
|
||||
GEOM_TYPE_MAP = {
|
||||
@ -581,16 +579,16 @@ class VectorWriter:
|
||||
raise GeoAlgorithmExecutionException("Couldn't connect to database")
|
||||
print uri.uri()
|
||||
try:
|
||||
db = postgis_utils.GeoDB(host=uri.host(), port=int(uri.port()),
|
||||
db = postgis.GeoDB(host=uri.host(), port=int(uri.port()),
|
||||
dbname=uri.database(), user=user, passwd=passwd)
|
||||
except postgis_utils.DbError as e:
|
||||
except postgis.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
"Couldn't connect to database:\n%s" % e.message)
|
||||
|
||||
def _runSQL(sql):
|
||||
try:
|
||||
db._exec_sql_and_commit(unicode(sql))
|
||||
except postgis_utils.DbError as e:
|
||||
except postgis.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Error creating output PostGIS table:\n%s' % e.message)
|
||||
|
||||
@ -612,15 +610,15 @@ class VectorWriter:
|
||||
uri = QgsDataSourceURI(self.destination[len(self.SPATIALITE_LAYER_PREFIX):])
|
||||
print uri.uri()
|
||||
try:
|
||||
db = spatialite_utils.GeoDB(uri=uri)
|
||||
except spatialite_utils.DbError as e:
|
||||
db = spatialite.GeoDB(uri=uri)
|
||||
except spatialite.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
"Couldn't connect to database:\n%s" % e.message)
|
||||
|
||||
def _runSQL(sql):
|
||||
try:
|
||||
db._exec_sql_and_commit(unicode(sql))
|
||||
except spatialite_utils.DbError as e:
|
||||
except spatialite.DbError as e:
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Error creating output Spatialite table:\n%s' % unicode(e))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user