Skip to content

Commit

Permalink
[processing] improved import to postgis algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jul 12, 2014
1 parent 1bf3be5 commit a58e648
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
Expand Up @@ -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'

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit a58e648

Please sign in to comment.