Skip to content

Commit 2e0576c

Browse files
stev-0nyalldawson
authored andcommitted
Fix quotes on postgis import, & fix mysql datsource formatting
(cherry-picked from 53cbe26)
1 parent 1c51d69 commit 2e0576c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

python/plugins/processing/algs/gdal/GdalUtils.py

+16
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,22 @@ def ogrConnectionStringAndFormatFromLayer(layer):
317317

318318
ogrstr = "PG:%s" % dsUri.connectionInfo()
319319
format = 'PostgreSQL'
320+
elif provider == 'mssql':
321+
#'dbname=\'db_name\' host=myHost estimatedmetadata=true
322+
# srid=27700 type=MultiPolygon table="dbo"."my_table"
323+
# #(Shape) sql='
324+
dsUri = layer.dataProvider().uri()
325+
ogrstr = 'MSSQL:'
326+
ogrstr += 'database={0};'.format(dsUri.database())
327+
ogrstr += 'server={0};'.format(dsUri.host())
328+
if dsUri.username() != "":
329+
ogrstr += 'uid={0};'.format(dsUri.username())
330+
else:
331+
ogrstr += 'trusted_connection=yes;'
332+
if dsUri.password() != '':
333+
ogrstr += 'pwd={0};'.format(dsUri.password())
334+
ogrstr += 'tables={0}'.format(dsUri.table())
335+
format = 'MSSQL'
320336
elif provider == "oracle":
321337
# OCI:user/password@host:port/service:table
322338
dsUri = QgsDataSourceUri(layer.dataProvider().dataSourceUri())

python/plugins/processing/algs/gdal/OgrToPostGis.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
234234
arguments.append('"' + shapeEncoding + '"')
235235
arguments.append('-f')
236236
arguments.append('PostgreSQL')
237-
arguments.append('PG:"')
238-
arguments.append(self.getConnectionString(parameters, context))
239-
arguments.append('"')
237+
arguments.append('PG:' + self.getConnectionString(parameters, context))
240238
arguments.append(dimstring)
241239
arguments.append(ogrLayer)
242240
arguments.append(layername)

0 commit comments

Comments
 (0)