[gdal-dev] [EXTERNAL] Re: ds.DeleteLayer(idx) "failed: database table is locked"
Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC]
jesse.r.meyer at nasa.gov
Thu Jan 30 11:09:25 PST 2025
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.rouault at 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.meyer at nasa.gov>, gdal dev <gdal-dev at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250130/b6576194/attachment.htm>
More information about the gdal-dev
mailing list