<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">The problem, as Germán found out, is that the URI passed as parameter</span><br style="font-size:12.8px"><span style="font-size:12.8px">is not necessarely an OGR provider URI, but a generic QGIS uri, from</span><br style="font-size:12.8px"><span style="font-size:12.8px">any provider, so it cannot always be opened via ogr.Open.</span></blockquote><div><br></div><div>Yes, ogr-sysntax must be used.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># -- Spatialite provider</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># dbname='/tmp/x.sqlite' table="t" (geometry) sql='</blockquote><div><br></div><div>would need to call 'GetLayerByName'</div><div><br></div><div>Here again there is a problem between gdal 1.* and gdal 2.*</div><div><br></div><div>Where there is a table with more than 1 geometry the syntax</div><div> 'tablename(fieldname)' can be used</div><div><br></div><div>In gdal 2.* that syntax can also be used with a table with only 1 geometry</div><div>- but not in gdal 1.*: there only the tablename can be used</div><div><br></div><div>sLayername="t(geometry)"; // ok for gdal 2.* or gdal 1.* with > 1 geometry</div><div>sLayername="t"; // ok for gdal 2.* or gdal 1.* with 1 geometry<br></div><div><br></div><div>ogrLayer = OGR_DS_GetLayerByName( ogrDataSource, TO8( sLayerName ) );<br></div><div><br></div><div>This should work for both PostgreSQL and spatialite based on your samples.</div><div><br></div><div>Mark Johnson</div></div>