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

2020-01-10 Thread Sandro Santilli
On Fri, Jan 10, 2020 at 09:55:33AM +0100, Sandro Santilli wrote: > On Thu, Jan 09, 2020 at 05:52:16PM +0100, Alessandro Pasotti wrote: > > > This works for me: > > > > vl = QgsVectorLayer( "dbname=qgis_tests host=localhost port=5432 > > key='__rid__' user=ale table=\"(SELECT row_number() OVER ()

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

2020-01-10 Thread Sandro Santilli
On Thu, Jan 09, 2020 at 05:52:16PM +0100, Alessandro Pasotti wrote: > This works for me: > > vl = QgsVectorLayer( "dbname=qgis_tests host=localhost port=5432 > key='__rid__' user=ale table=\"(SELECT row_number() OVER () AS __rid__, * > FROM (SELECT * FROM raster_columns) AS foo)\" schema=public",

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

2020-01-10 Thread Tim Sutton
Oops sorry I didn't read it carefully enough! Regards Tim On Fri, Jan 10, 2020, 8:03 AM Alessandro Pasotti wrote: > > > On Thu, Jan 9, 2020 at 11:26 PM Tim Sutton wrote: > >> >>> >>> In particular, me an Nyall have been chatting about adding a method to >>> factory a QgsVectorLayer from a ge

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

2020-01-10 Thread Alessandro Pasotti
On Thu, Jan 9, 2020 at 11:26 PM Tim Sutton 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 m

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

2020-01-09 Thread Tim Sutton
> > > > 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 transparent

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

2020-01-09 Thread Alessandro Pasotti
On Thu, Jan 9, 2020 at 12:36 PM Sandro Santilli wrote: > Hi all, > some of you might know already I've been working on improving the > DBManager SQL Window so so not rely on "psycopg2" when interacting > with PostgreSQL backend. This work is in progress in this PR: > > https://github.com/qgis/Q

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

2020-01-09 Thread Sandro Santilli
Hi all, some of you might know already I've been working on improving the DBManager SQL Window so so not rely on "psycopg2" when interacting with PostgreSQL backend. This work is in progress in this PR: https://github.com/qgis/QGIS/pull/33225 The advice, from Alessandro, was to use the new core