[QGIS-Developer] core API to fetch query output fields from SQL query?

Alessandro Pasotti apasotti at gmail.com
Fri Jan 10 00:03:21 PST 2020


On Thu, Jan 9, 2020 at 11:26 PM Tim Sutton <tim at kartoza.com> wrote:

>
>>
>> In particular, me an Nyall have been chatting about adding a method to
>> factory a QgsVectorLayer from a generic SQL query, the issues I see is that
>> we need a PK (at least for PG) and how to decide the geometry column if
>> there are more than one.
>>
>
> I wonder if you could just transparently add row_number[1] to the query to
> give each row a unique id?
>
> Regards
>
> Tim
>
> [1] https://www.postgresqltutorial.com/postgresql-row_number/
>
>

Hi Tim,

the example query I pasted in my original email does exactly that:  (SELECT
row_number()....

we just need a bit of login to determine when/if we have to make that trick.


-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200110/c7e13730/attachment.html>


More information about the QGIS-Developer mailing list