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", 'layer', > 'postgres')
Ok, I've taken this path [1]. My mistake was using .setDataSource, which insists in taking a geometry column name. Of course, as expected, doing the QgsVectorLayer dance degrades startup costs as very many vector layers will be created, and there's a number of operations that are done by the PostgreSQL provider when creating such layers (such as retrieving capabilities of the provider). [1] xxxxx > Also, the vector API uses an iterator, so chunk retrieval is definitely > possible. Uhm, this would be interesting, does the chunk retrieval depend on key generated by "row_number" as well ? The only downsides I see with using this approach would be: 1. The cost of creating a QgsVectorLayer 2. The need to provide a syntetic primary key 3. (not sure about this): the need to support non-SELECT statements --strk; _______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer