qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.32k stars 2.96k forks source link

'PostgreSQL execute SQL' does not accept algorithm output as SQL query #41299

Open brusspi opened 3 years ago

brusspi commented 3 years ago

When using the algorithm 'PostgreSQL execute SQL', it is not possible to select an algorithm output as input in the SQL query. Also the 'pre-calculated value' gives an empty SQL-query in the log: 2021-02-01 19_43_03-Insert_into_db

more info: https://gis.stackexchange.com/questions/352724/sql-insert-into-tablevalues-using-qgis-modeller

I'm using QGIS 3.16 on windows

gioman commented 3 years ago

@brusspi no of course, because with 'PostgreSQL execute SQL' you can run a queries against tables/layers that exist on a particular PostgreSQL endpoint, not a temp layer/table coming out of an algorithm in the QGIS modeller on your computer.

brusspi commented 3 years ago

@gioman Maybe I did not explain well. The model output of the previous algorithm is an SQL-query like 'insert into table (field1, field2) values ('valueA',' valueB'), ('valueC','valueD')'. This result should be ported to the 'PostgreSQL execute SQL' algorithm with

afbeelding or it can be performed by 'Pre-calculated Value'. But both options does not work.

As you can see in the picture above: it returns an empty string into the parameters. It says {DATABASE: postgis_25_sample, SQL: ' ' }

This is the workflow:

afbeelding

gioman commented 3 years ago

As you can see in the picture above: it returns an empty string into the parameters. It says {DATABASE: postgis_25_sample, SQL: ' ' }

@brusspi try casting that to string (should be "to_string").

brusspi commented 3 years ago

I tried to cast to_string(). But nothing happens. It seems like the variable coming out of 'generate SQL-query' could not be read.

gioman commented 3 years ago

coming out of 'generate SQL-query'

@brusspi is this a core tool?

brusspi commented 3 years ago

it is the 'Execute SQL'-algorithm

afbeelding

It produces a layer with 1 attribute, containing the query.

afbeelding

alexbruy commented 3 years ago

You can't use layer value as input for string parameter.

brusspi commented 3 years ago

@alexbruy : So it is not a bug?

@gioman: If it is not a bug, can my question be changed to 'feature request'?

brusspi commented 2 years ago

I think these issues are related to my question:

https://github.com/qgis/QGIS/issues/37347 and https://github.com/qgis/QGIS/issues/30397

tragewegen commented 10 months ago

@gioman: who do we have to contact to ask for more information to develop this featurerequest?

elpaso commented 10 months ago

@tragewegen if you are looking for commercial support here is a list of companies: https://www.qgis.org/en/site/forusers/commercial_support.html