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