Sample data for testing available here (the model described below is embedded in the QGIS project file)
In the context of a QGIS model, I am struggling to pass input parameters as part of a SQL query to be used in the Execute SQL tool.
I have this model:
And I use a pre-calculated expression as follows:
select
row_number() over() as id,
min('||@Fieldcontainingthecentralityscores||') as min,
('||@FieldcontainingtheHierarchylevel||') as hierarchy
from '||@MatrixofFunctions||'
group by hierarchy'
The screenshot:
As you can see, what I do is to try to grab model-specific variables denoted by the @
However when I run the model I get this message:
Prepare algorithm: gdal:executesql_1
Running Execute SQL [1/1]
Input Parameters:
{ DIALECT: 0, INPUT: 'C:/Users/DaSilvaA/Desktop/oromia_MoF/Oromia_(incl_Addis)_MoF_final.gpkg|layername=Oromia_(incl_Addis)_MoF_final', OPTIONS: '', OUTPUT: 'TEMPORARY_OUTPUT', SQL: 'select \r\n\trow_number() over() as id, \r\n\tmin(centrality_score) as min, \r\n\t(Oromia_MoF_oct_2022_c_Hierarchy Level) as hierarchy\r\nfrom \r\ngroup by hierarchy' }
GDAL command:
ogr2ogr C:/Users/DaSilvaA/AppData/Local/Temp/processing_YDUAJo/3d541238b96f4b6cb5d51a547ba2f4ac/OUTPUT.gpkg "C:/Users/DaSilvaA/Desktop/oromia_MoF/Oromia_(incl_Addis)_MoF_final.gpkg" -sql "select
row_number() over() as id,
min(centrality_score) as min,
(Oromia_MoF_oct_2022_c_Hierarchy Level) as hierarchy
from
group by hierarchy" -f "GPKG"
GDAL command output:
ERROR 1: In ExecuteSQL(): sqlite3_prepare_v2(select ):
incomplete input
I have tried many variations to the expression syntax formulation but in the end the model parameters do not pass into the query.
Does anyone know how to have input parameters interpreted in a SQL query inside a QGIS model?







