> The problem, as Germán found out, is that the URI passed as parameter
> is not necessarely an OGR provider URI, but a generic QGIS uri, from
> any provider, so it cannot always be opened via ogr.Open.
Yes, ogr-sysntax must be used.
# -- Spatialite provider
# dbname='/tmp/x.sqlite' table="t" (geometry) sql='
would need to call 'GetLayerByName'
Here again there is a problem between gdal 1.* and gdal 2.*
Where there is a table with more than 1 geometry the syntax
'tablename(fieldname)' can be used
In gdal 2.* that syntax can also be used with a table with only 1 geometry
- but not in gdal 1.*: there only the tablename can be used
sLayername="t(geometry)"; // ok for gdal 2.* or gdal 1.* with > 1 geometry
sLayername="t"; // ok for gdal 2.* or gdal 1.* with 1 geometry
ogrLayer = OGR_DS_GetLayerByName( ogrDataSource, TO8( sLayerName ) );
This should work for both PostgreSQL and spatialite based on your samples.
Qgis-developer mailing list
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer