Thanks Evan, Yes, the dataset is open with the update flag set.
It’s a bit awkward because I want to replace the layer with the layer returned by the query. If I do the naïve “ds.CopyLayer(sql_lyr, layer_name, options=[“OVERWRITE=YES”]) this appears to enter into an infinite loop. So looks like I need to do this manually. Best, Jesse Lead Computer Scientist Science Systems and Applications, Inc. Dr Compton Tucker Team NASA Goddard Space Flight Center From: Even Rouault <even.roua...@spatialys.com> Date: Thursday, January 30, 2025 at 1:47 PM To: Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] <jesse.r.me...@nasa.gov>, gdal dev <gdal-dev@lists.osgeo.org> Subject: [EXTERNAL] Re: [gdal-dev] ds.DeleteLayer(idx) "failed: database table is locked" CAUTION: This email originated from outside of NASA. Please take care when clicking links or opening attachments. Use the "Report Message" button to report suspicious messages to the NASA SOC. Jessy, Trying to remove superfluous intermediate layers in a GPKG dataset. The general logic is Ds = ogr.open(fp) I assume you meant ogr.Open(fp, update=True) otherwise you'd got another type of error. Lyr = ds.executesql(query) Ds.DeleteLayer(idx) <- failed, database table is locked, may be caused by “sqlite3_exec(DROP TABLE “rtree_layername_geom”) failed: database table is locked Is layer deletion not supported while a “result set” from a SQL query is on the dataset is active? Perhaps importantly, the query sources the deleted layer. Yes most likely. Calling ds.ReleaseResultSet(Lyr) before should make things work. You could possibly also try to open the dataset after setting gdal.SetConfigOption("OGR_SQLITE_JOURNAL", "WAL") , but I'm not positive at all this would avoid this particular issue. Even -- http://www.spatialys.com<http://www.spatialys.com/> My software is free, but my time generally not. Grumpy maintainer. "De l'égo à l'égoût, il n'y a qu'une bouche mal refermée", André Isaac
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev