Get supported extension to avoid unavailable driver

This commit is contained in:
Julien Cabieces 2019-07-04 09:54:32 +02:00 committed by Nyall Dawson
parent 4232e67c3d
commit 36fe8e64e3

View File

@ -136,7 +136,8 @@ class ExecuteSQL(QgisAlgorithm):
# belongs to temporary QgsMapLayerStore, not project.
# So, we write them to disk is this is the case.
if not QgsProject.instance().mapLayer(layer.id()):
tf = tempfile.NamedTemporaryFile(suffix=".gpkg")
suffix = "." + QgsVectorFileWriter.supportedFormatExtensions()[0]
tf = tempfile.NamedTemporaryFile(suffix=suffix)
tmp_path = tf.name
QgsVectorFileWriter.writeAsVectorFormat(
layer, tmp_path, layer.dataProvider().encoding())