2828from processing .core .GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
2929from processing .core .parameters import ParameterVector
3030from processing .core .parameters import ParameterString
31+ from processing .core .parameters import ParameterSelection
3132from processing .core .outputs import OutputVector
3233
3334from processing .algs .gdal .GdalUtils import GdalUtils
3435from processing .algs .gdal .OgrAlgorithm import OgrAlgorithm
3536
3637
38+ DIALECTS = [None , 'ogrsql' , 'sqlite' ]
39+
3740class OgrSql (OgrAlgorithm ):
3841
3942 INPUT = 'INPUT'
4043 OUTPUT = 'OUTPUT'
4144 SQL = 'SQL'
45+ DIALECT = 'DIALECT'
4246
4347 def defineCharacteristics (self ):
4448 self .name , self .i18n_name = self .trAlgorithm ('Execute SQL' )
@@ -48,6 +52,12 @@ def defineCharacteristics(self):
4852 [ParameterVector .VECTOR_TYPE_ANY ], False ))
4953 self .addParameter (ParameterString (self .SQL , self .tr ('SQL' ), '' ))
5054
55+ self .addParameter (ParameterSelection (
56+ self .DIALECT ,
57+ self .tr ('Dialect' ),
58+ DIALECTS )
59+ )
60+
5161 self .addOutput (OutputVector (self .OUTPUT , self .tr ('SQL result' )))
5262
5363 def getConsoleCommands (self ):
@@ -60,6 +70,13 @@ def getConsoleCommands(self):
6070 arguments .append ('-sql' )
6171 arguments .append (sql )
6272
73+ dialectIdx = self .getParameterValue (self .DIALECT )
74+ dialect = DIALECTS [dialectIdx ]
75+
76+ if dialect :
77+ arguments .append ("-dialect" )
78+ arguments .append (dialect )
79+
6380 output = self .getOutputFromName (self .OUTPUT )
6481 outFile = output .value
6582 arguments .append (outFile )
0 commit comments