Skip to content
Permalink
Browse files

[feature] Add parameter for field selection to Postgis OGR importer

  • Loading branch information
stev-0 authored and nyalldawson committed Aug 8, 2018
1 parent 53cbe26 commit 56e605bdd1edcd8c0934397c85efca4114f826a1
Showing with 9 additions and 0 deletions.
  1. +9 −0 python/plugins/processing/algs/gdal/OgrToPostGis.py
@@ -65,6 +65,7 @@ class OgrToPostGis(GdalAlgorithm):
SEGMENTIZE = 'SEGMENTIZE'
SPAT = 'SPAT'
CLIP = 'CLIP'
FIELDS = 'FIELDS'
WHERE = 'WHERE'
GT = 'GT'
OVERWRITE = 'OVERWRITE'
@@ -127,6 +128,10 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterBoolean(self.CLIP,
self.tr('Clip the input layer using the above (rectangle) extent'),
defaultValue=False))
self.addParameter(QgsProcessingParameterField(self.FIELDS,
self.tr('Fields to include (leave empty to use all fields)'),
parentLayerParameterName=self.INPUT,
allowMultiple=True, optional=True))
self.addParameter(QgsProcessingParameterString(self.WHERE,
self.tr('Select features using a SQL "WHERE" statement (Ex: column=\'value\')'),
defaultValue='', optional=True))
@@ -210,6 +215,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
segmentize = self.parameterAsString(parameters, self.SEGMENTIZE, context)
spat = self.parameterAsExtent(parameters, self.SPAT, context)
clip = self.parameterAsBool(parameters, self.CLIP, context)
include_fields = self.parameterAsFields(parameters, self.FIELDS, context)
fields_string = '-select "' + ','.join(include_fields) + '"'
where = self.parameterAsString(parameters, self.WHERE, context)
wherestring = '-where "' + where + '"'
gt = self.parameterAsString(parameters, self.GT, context)
@@ -244,6 +251,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(launderstring)
if append:
arguments.append('-append')
if include_fields:
arguments.append(fields_string)
if addfields:
arguments.append('-addfields')
if overwrite:

0 comments on commit 56e605b

Please sign in to comment.
You can’t perform that action at this time.