mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Add a dialect select to ogrsql
Add the ability to select sqlite or ogrsql dialects when executing SQL Signed-off-by: Henry Walshaw <henry.walshaw@gmail.com>
This commit is contained in:
parent
4c1e056971
commit
524f6ab460
@ -28,17 +28,21 @@ __revision__ = '$Format:%H$'
|
||||
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
|
||||
from processing.core.parameters import ParameterVector
|
||||
from processing.core.parameters import ParameterString
|
||||
from processing.core.parameters import ParameterSelection
|
||||
from processing.core.outputs import OutputVector
|
||||
|
||||
from processing.algs.gdal.GdalUtils import GdalUtils
|
||||
from processing.algs.gdal.OgrAlgorithm import OgrAlgorithm
|
||||
|
||||
|
||||
DIALECTS = [None, 'ogrsql', 'sqlite']
|
||||
|
||||
class OgrSql(OgrAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT = 'OUTPUT'
|
||||
SQL = 'SQL'
|
||||
DIALECT = 'DIALECT'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name, self.i18n_name = self.trAlgorithm('Execute SQL')
|
||||
@ -48,6 +52,12 @@ class OgrSql(OgrAlgorithm):
|
||||
[ParameterVector.VECTOR_TYPE_ANY], False))
|
||||
self.addParameter(ParameterString(self.SQL, self.tr('SQL'), ''))
|
||||
|
||||
self.addParameter(ParameterSelection(
|
||||
self.DIALECT,
|
||||
self.tr('Dialect'),
|
||||
DIALECTS)
|
||||
)
|
||||
|
||||
self.addOutput(OutputVector(self.OUTPUT, self.tr('SQL result')))
|
||||
|
||||
def getConsoleCommands(self):
|
||||
@ -60,6 +70,13 @@ class OgrSql(OgrAlgorithm):
|
||||
arguments.append('-sql')
|
||||
arguments.append(sql)
|
||||
|
||||
dialectIdx = self.getParameterValue(self.DIALECT)
|
||||
dialect = DIALECTS[dialectIdx]
|
||||
|
||||
if dialect:
|
||||
arguments.append("-dialect")
|
||||
arguments.append(dialect)
|
||||
|
||||
output = self.getOutputFromName(self.OUTPUT)
|
||||
outFile = output.value
|
||||
arguments.append(outFile)
|
||||
|
Loading…
x
Reference in New Issue
Block a user