Skip to content

Commit

Permalink
Fix quotes on postgis import, & fix mysql datsource formatting
Browse files Browse the repository at this point in the history
(cherry-picked from 53cbe26)
  • Loading branch information
stev-0 authored and nyalldawson committed Aug 8, 2018
1 parent 1c51d69 commit 2e0576c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 16 additions & 0 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -317,6 +317,22 @@ def ogrConnectionStringAndFormatFromLayer(layer):

ogrstr = "PG:%s" % dsUri.connectionInfo()
format = 'PostgreSQL'
elif provider == 'mssql':
#'dbname=\'db_name\' host=myHost estimatedmetadata=true
# srid=27700 type=MultiPolygon table="dbo"."my_table"
# #(Shape) sql='
dsUri = layer.dataProvider().uri()
ogrstr = 'MSSQL:'
ogrstr += 'database={0};'.format(dsUri.database())
ogrstr += 'server={0};'.format(dsUri.host())
if dsUri.username() != "":
ogrstr += 'uid={0};'.format(dsUri.username())
else:
ogrstr += 'trusted_connection=yes;'
if dsUri.password() != '':
ogrstr += 'pwd={0};'.format(dsUri.password())
ogrstr += 'tables={0}'.format(dsUri.table())
format = 'MSSQL'
elif provider == "oracle":
# OCI:user/password@host:port/service:table
dsUri = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
Expand Down
4 changes: 1 addition & 3 deletions python/plugins/processing/algs/gdal/OgrToPostGis.py
Expand Up @@ -234,9 +234,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('"' + shapeEncoding + '"')
arguments.append('-f')
arguments.append('PostgreSQL')
arguments.append('PG:"')
arguments.append(self.getConnectionString(parameters, context))
arguments.append('"')
arguments.append('PG:' + self.getConnectionString(parameters, context))
arguments.append(dimstring)
arguments.append(ogrLayer)
arguments.append(layername)
Expand Down

0 comments on commit 2e0576c

Please sign in to comment.