28
28
from processing .core .GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
29
29
from processing .core .parameters import ParameterVector
30
30
from processing .core .parameters import ParameterString
31
+ from processing .core .parameters import ParameterSelection
31
32
from processing .core .outputs import OutputVector
32
33
33
34
from processing .algs .gdal .GdalUtils import GdalUtils
34
35
from processing .algs .gdal .OgrAlgorithm import OgrAlgorithm
35
36
36
37
38
+ DIALECTS = [None , 'ogrsql' , 'sqlite' ]
39
+
37
40
class OgrSql (OgrAlgorithm ):
38
41
39
42
INPUT = 'INPUT'
40
43
OUTPUT = 'OUTPUT'
41
44
SQL = 'SQL'
45
+ DIALECT = 'DIALECT'
42
46
43
47
def defineCharacteristics (self ):
44
48
self .name , self .i18n_name = self .trAlgorithm ('Execute SQL' )
@@ -48,6 +52,12 @@ def defineCharacteristics(self):
48
52
[ParameterVector .VECTOR_TYPE_ANY ], False ))
49
53
self .addParameter (ParameterString (self .SQL , self .tr ('SQL' ), '' ))
50
54
55
+ self .addParameter (ParameterSelection (
56
+ self .DIALECT ,
57
+ self .tr ('Dialect' ),
58
+ DIALECTS )
59
+ )
60
+
51
61
self .addOutput (OutputVector (self .OUTPUT , self .tr ('SQL result' )))
52
62
53
63
def getConsoleCommands (self ):
@@ -60,6 +70,13 @@ def getConsoleCommands(self):
60
70
arguments .append ('-sql' )
61
71
arguments .append (sql )
62
72
73
+ dialectIdx = self .getParameterValue (self .DIALECT )
74
+ dialect = DIALECTS [dialectIdx ]
75
+
76
+ if dialect :
77
+ arguments .append ("-dialect" )
78
+ arguments .append (dialect )
79
+
63
80
output = self .getOutputFromName (self .OUTPUT )
64
81
outFile = output .value
65
82
arguments .append (outFile )
0 commit comments