Skip to content
Permalink
Browse files
[processing] Add option to Import into PostGIS algorithm to drop leng…
…th constraints on character fields
  • Loading branch information
nyalldawson committed May 20, 2014
1 parent 3470b1d commit 2eda53390b3007e6c168b43be798530e37bb3e74
Showing with 6 additions and 0 deletions.
  1. +6 −0 python/plugins/processing/algs/admintools/ImportIntoPostGIS.py
@@ -50,6 +50,7 @@ class ImportIntoPostGIS(GeoAlgorithm):
CREATEINDEX = 'CREATEINDEX'
GEOMETRY_COLUMN = 'GEOMETRY_COLUMN'
LOWERCASE_NAMES = 'LOWERCASE_NAMES'
DROP_STRING_LENGTH = 'DROP_STRING_LENGTH'

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../../images/postgis.png')
@@ -60,6 +61,7 @@ def processAlgorithm(self, progress):
overwrite = self.getParameterValue(self.OVERWRITE)
createIndex = self.getParameterValue(self.CREATEINDEX)
convertLowerCase = self.getParameterValue(self.LOWERCASE_NAMES)
dropStringLength = self.getParameterValue(self.DROP_STRING_LENGTH)
settings = QSettings()
mySettings = '/PostgreSQL/connections/' + connection
try:
@@ -96,6 +98,8 @@ def processAlgorithm(self, progress):
options['overwrite'] = True
if convertLowerCase:
options['lowercaseFieldNames'] = True
if dropStringLength:
options['dropStringConstraints'] = True
layerUri = self.getParameterValue(self.INPUT)
layer = dataobjects.getObjectFromUri(layerUri)
(ret, errMsg) = QgsVectorLayerImport.importLayer(
@@ -140,3 +144,5 @@ def defineCharacteristics(self):
'Create spatial index', True))
self.addParameter(ParameterBoolean(self.LOWERCASE_NAMES,
'Convert field names to lowercase', False))
self.addParameter(ParameterBoolean(self.DROP_STRING_LENGTH,
'Drop length constraints on character fields', False))

0 comments on commit 2eda533

Please sign in to comment.