<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Jessy,<o:p> <br>
    </o:p>
    <blockquote type="cite"
cite="mid:DM6PR09MB5927BBC9B8B5F5D929D6336FC9E92@DM6PR09MB5927.namprd09.prod.outlook.com">
      <div class="WordSection1">
        <p class="MsoNormal">Trying to remove superfluous intermediate
          layers in a GPKG dataset.  The general logic is<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Ds = ogr.open(fp)</p>
      </div>
    </blockquote>
    <p>I assume you meant ogr.Open(fp, update=True) otherwise you'd got
      another type of error.<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
cite="mid:DM6PR09MB5927BBC9B8B5F5D929D6336FC9E92@DM6PR09MB5927.namprd09.prod.outlook.com">
      <div class="WordSection1">
        <p class="MsoNormal"><o:p></o:p></p>
        <p class="MsoNormal">Lyr = ds.executesql(query)<o:p></o:p></p>
        <p class="MsoNormal">Ds.DeleteLayer(idx) <- failed, database
          table is locked, may be caused by “sqlite3_exec(DROP TABLE
          “rtree_layername_geom”) failed: database table is locked<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">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.<o:p></o:p></p>
      </div>
    </blockquote>
    <p>Yes most likely. Calling ds.ReleaseResultSet(Lyr) before should
      make things work.<br>
    </p>
    <p>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.<br>
    </p>
    Even
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
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</pre>
  </body>
</html>