Skip to content
Permalink
Browse files

[processing] Ignore geom for non geom tables for ImportIntoPostGIS

This fixes an error where trying to import non geometry tables
using the "Import Into PostGIS" algorithm results in a database
error.
  • Loading branch information
nyalldawson committed Oct 27, 2014
1 parent 4e3bbef commit 3be82ff7083ae9fe857499ca99ec25790734e81e
Showing with 5 additions and 1 deletion.
  1. +5 −1 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
@@ -103,6 +103,10 @@ def processAlgorithm(self, progress):
if dropStringLength:
options['dropStringConstraints'] = True

#clear geometry column for non-geometry tables
if not layer.hasGeometryType():
geomColumn = None

uri = QgsDataSourceURI()
uri.setConnection(host, str(port), database, username, password)
if primaryKeyField:
@@ -123,7 +127,7 @@ def processAlgorithm(self, progress):
raise GeoAlgorithmExecutionException(
'Error importing to PostGIS\n%s' % errMsg)

if createIndex:
if geomColumn and createIndex:
db.create_spatial_index(table, schema, geomColumn)

db.vacuum_analyze(table, schema)

0 comments on commit 3be82ff

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