Selon Martin Landa <landa.mar...@gmail.com>: > Hi all, > > sample script to reproduce: > > """ > from osgeo import ogr > > odrv = ogr.GetDriverByName("PostgreSQL") > ods = odrv.Open("PG:dbname=pgis_vfr", True) > layerName = 'obce' > if not ods.GetLayerByName(layerName): > print "Layer not found, creating..." > ods.CreateLayer(layerName, None, ogr.wkbPoint, []) > else: > print "Layer found" > > ods.SyncToDisk() > ods.Destroy() > """ > > 1) first run - table exists in DB > > Layer found > > 2) drop table obce; > > 3) second run > > ERROR 1: No field definitions found for 'obce', is it a table? > <- this goes from GetLayerByName() / ReadTableDefinition() > <- why report it as an error, I just what to check if layer exists...
Since that path is also taken when discovering existing spatial layers, this could make some sense at the time where geometry_columns was a table and not a view as in PostGIS 2.X now, and you could imagine some inconsistency where a table would remain declared in geometry_columns but did not exist. > > Layer not found, creating... > > Using GDAL 1.12dev, PostGIS 2.1. Is it new to the -dev version ? I don't think so, but anyway, feel free to change the error into a CPLDebug message. The error seems to be emitted there http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp#L380 > > Thanks, Martin > > -- > Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev > _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev