Skip to content
Permalink
Browse files

[processing] add ability to choose encoding when importing into PostG…

…IS (fix #14687)
  • Loading branch information
alexbruy committed May 24, 2016
1 parent 9928980 commit 8ad1e3c8bcdadf3ce781f5ba260f177c4cc9acc7
Showing with 8 additions and 0 deletions.
  1. +8 −0 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
@@ -51,6 +51,7 @@ class ImportIntoPostGIS(GeoAlgorithm):
LOWERCASE_NAMES = 'LOWERCASE_NAMES'
DROP_STRING_LENGTH = 'DROP_STRING_LENGTH'
PRIMARY_KEY = 'PRIMARY_KEY'
ENCODING = 'ENCODING'

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Import into PostGIS')
@@ -69,6 +70,9 @@ def defineCharacteristics(self):
self.tr('Primary key field'), self.INPUT, optional=True))
self.addParameter(ParameterString(self.GEOMETRY_COLUMN,
self.tr('Geometry column'), 'geom'))
self.addParameter(ParameterString(self.ENCODING,
self.tr('Encoding'), 'UTF-8',
optional=True))
self.addParameter(ParameterBoolean(self.OVERWRITE,
self.tr('Overwrite'), True))
self.addParameter(ParameterBoolean(self.CREATEINDEX,
@@ -86,6 +90,7 @@ def processAlgorithm(self, progress):
convertLowerCase = self.getParameterValue(self.LOWERCASE_NAMES)
dropStringLength = self.getParameterValue(self.DROP_STRING_LENGTH)
primaryKeyField = self.getParameterValue(self.PRIMARY_KEY)
encoding = self..getParameterValue(self.ENCODING)

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn May 24, 2016

Member

is that double .. intentional?

settings = QSettings()
mySettings = '/PostgreSQL/connections/' + connection
try:
@@ -138,6 +143,9 @@ def processAlgorithm(self, progress):
else:
uri.setDataSource(schema, table, geomColumn, '')

if encoding:
layer.setProviderEncoding(encoding)

(ret, errMsg) = QgsVectorLayerImport.importLayer(
layer,
uri.uri(),

0 comments on commit 8ad1e3c

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