I am getting an error "ogr error committing transaction: sqlite3_exe(COMMIT) failed: database is locked" when trying to edit a feature on a geopackage layer using pyqgis. It is a QGIS plugin. Everything works fine on my hard drive, the problem occurs when I load the file to a server.
I have found https://github.com/r-spatial/sf/issues/628 which seems similar. This also - How to update attributes on spatialite table programmatically: SQLite Error
def save_point(self):
try:
node_lyr_name = 'points'
node_point = QgsPoint(-83.433, 44.466, 725.000)
point_id = "2001"
node_lyr = QgsProject.instance().mapLayersByName(node_lyr_name)[0]
features = node_lyr.getFeatures()
node_lyr.startEditing()
for feature1 in features:
if feature1['ID'] == point_id:
feature1.setGeometry(node_point)
feature1['Name'] = self.dlg.le_yourname.text()
node_lyr.updateFeature(feature1)
break
node_lyr.commitChanges()
node_lyr.triggerRepaint()
except Exception as inst:
self.popMsg(str(inst) + "\n Exception #1561 for row in save_point(): \n" )
print(type(inst))
print(inst.args)
print(inst, ' #1604')
Is there anything different I need to do when working with a geopackage?
[EDIT] the below code also fails with the same error. :(
vectorLayer = iface.activeLayer()
features = vectorLayer.getFeatures()
fid = int()
for feature in features:
if feature['ID'] == "2016":
fid= feature.id()
break
field = vectorLayer.fields().indexFromName('Name')
print(f'Field {field}')
with edit(vectorLayer):
vectorLayer.changeAttributeValue(fid, field, 'Hello')