@@ -153,19 +153,35 @@ def defineCharacteristics(self):
153
153
self .addParameter (ParameterString (self .OPTIONS ,
154
154
self .tr ('Additional creation options' ), '' , optional = True ))
155
155
156
+ def getConnectionString (self ):
157
+ host = unicode (self .getParameterValue (self .HOST ))
158
+ port = unicode (self .getParameterValue (self .PORT ))
159
+ user = unicode (self .getParameterValue (self .USER ))
160
+ dbname = unicode (self .getParameterValue (self .DBNAME ))
161
+ password = unicode (self .getParameterValue (self .PASSWORD ))
162
+ schema = unicode (self .getParameterValue (self .SCHEMA ))
163
+ arguments = []
164
+ if host :
165
+ arguments .append ('host=' + host )
166
+ if port :
167
+ arguments .append ('port=' + port )
168
+ if dbname :
169
+ arguments .append ('dbname=' + dbname )
170
+ if password :
171
+ arguments .append ('password=' + password )
172
+ if schema :
173
+ arguments .append ('active_schema=' + schema )
174
+ if user :
175
+ arguments .append ('user=' + user )
176
+ return GdalUtils .escapeAndJoin (arguments )
177
+
156
178
def getConsoleCommands (self ):
157
179
inLayer = self .getParameterValue (self .INPUT_LAYER )
158
180
ogrLayer = ogrConnectionString (inLayer )[1 :- 1 ]
159
181
shapeEncoding = self .getParameterValue (self .SHAPE_ENCODING )
160
182
ssrs = unicode (self .getParameterValue (self .S_SRS ))
161
183
tsrs = unicode (self .getParameterValue (self .T_SRS ))
162
184
asrs = unicode (self .getParameterValue (self .A_SRS ))
163
- host = unicode (self .getParameterValue (self .HOST ))
164
- port = unicode (self .getParameterValue (self .PORT ))
165
- user = unicode (self .getParameterValue (self .USER ))
166
- dbname = unicode (self .getParameterValue (self .DBNAME ))
167
- password = unicode (self .getParameterValue (self .PASSWORD ))
168
- schema = unicode (self .getParameterValue (self .SCHEMA ))
169
185
table = unicode (self .getParameterValue (self .TABLE ))
170
186
pk = unicode (self .getParameterValue (self .PK ))
171
187
pkstring = "-lco FID=" + pk
@@ -203,18 +219,7 @@ def getConsoleCommands(self):
203
219
arguments .append ('-f' )
204
220
arguments .append ('PostgreSQL' )
205
221
arguments .append ('PG:"' )
206
- if host :
207
- arguments .append (' host=' + host )
208
- if port :
209
- arguments .append ('port=' + port )
210
- if dbname :
211
- arguments .append ('dbname=' + dbname )
212
- if password :
213
- arguments .append ('password=' + password )
214
- if schema :
215
- arguments .append ('active_schema=' + schema )
216
- if user :
217
- arguments .append ('user=' + user )
222
+ arguments .append (self .getConnectionString ())
218
223
arguments .append ('"' )
219
224
arguments .append (dimstring )
220
225
arguments .append (ogrLayer )
0 commit comments