Skip to content
Permalink
Browse files
[processing] improved import to postgis algorithm
  • Loading branch information
volaya committed Jul 12, 2014
1 parent 1bf3be5 commit a58e64897cbcd6d9f640d529b9db911fb3af6e5d
Showing with 8 additions and 5 deletions.
  1. +8 −5 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
@@ -74,7 +74,12 @@ def processAlgorithm(self, progress):
raise GeoAlgorithmExecutionException(
'Wrong database connection name: ' + connection)

table = self.getParameterValue(self.TABLENAME)
layerUri = self.getParameterValue(self.INPUT)
layer = dataobjects.getObjectFromUri(layerUri)

table = self.getParameterValue(self.TABLENAME).strip()
if table == '':
table = layer.name().lower()
table.replace(' ', '')
providerName = 'postgres'

@@ -105,8 +110,6 @@ def processAlgorithm(self, progress):
else:
uri.setDataSource(schema, table, geomColumn, '')

layerUri = self.getParameterValue(self.INPUT)
layer = dataobjects.getObjectFromUri(layerUri)
(ret, errMsg) = QgsVectorLayerImport.importLayer(
layer,
uri.uri(),
@@ -139,8 +142,8 @@ def defineCharacteristics(self):
self.addParameter(ParameterSelection(self.DATABASE, 'Database (connection name)',
self.DB_CONNECTIONS))

self.addParameter(ParameterString(self.SCHEMA, 'Schema (schema name)'))
self.addParameter(ParameterString(self.TABLENAME, 'Table to import to'
self.addParameter(ParameterString(self.SCHEMA, 'Schema (schema name)', 'public'))
self.addParameter(ParameterString(self.TABLENAME, 'Table to import to (leave blank to use layer name)'
))
self.addParameter(ParameterTableField(self.PRIMARY_KEY, 'Primary key field',
self.INPUT, optional=True))

0 comments on commit a58e648

Please sign in to comment.