Skip to main content
added 109 characters in body; edited tags; edited title
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Adding 'Opening of data source in update mode failed (OGR error: )' error when adding layer to GeoPackage using PyQGIS

While running the following code:

canvas =from qgis.utils import iface
from qgis.core import QgsVectorFileWriter

canvas = iface.mapCanvas()
layer = canvas.currentLayer()
print(layer.name()) 

options = QgsVectorFileWriter.SaveVectorOptions()
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)
print(writer)

I got this error:

(2, 'Opening of data source in update mode failed (OGR error: )')

(2, 'Opening of data source in update mode failed (OGR error: )')

The layer is created by with:

from qgis.core import QgsVectorLayer

layer = QgsVectorLayer("Point", 'layerName', "memory")

I tried to use this solution: Adding layer to GeoPackage using PyQGIS but it is not working for me.

Adding layer to GeoPackage

While running the following code

canvas = qgis.utils.iface.mapCanvas()
layer = canvas.currentLayer()
print(layer.name())
options = QgsVectorFileWriter.SaveVectorOptions()
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)
print(writer)

I got this error:

(2, 'Opening of data source in update mode failed (OGR error: )')

The layer is created by with

layer = QgsVectorLayer("Point", 'layerName', "memory")

I tried to use this solution: Adding layer to GeoPackage using PyQGIS but it is not working for me.

'Opening of data source in update mode failed (OGR error: )' error when adding layer to GeoPackage using PyQGIS

While running the following code:

from qgis.utils import iface
from qgis.core import QgsVectorFileWriter

canvas = iface.mapCanvas()
layer = canvas.currentLayer()
print(layer.name()) 

options = QgsVectorFileWriter.SaveVectorOptions()
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)
print(writer)

I got this error:

(2, 'Opening of data source in update mode failed (OGR error: )')

The layer is created by with:

from qgis.core import QgsVectorLayer

layer = QgsVectorLayer("Point", 'layerName', "memory")

I tried to use this solution: Adding layer to GeoPackage using PyQGIS but it is not working for me.

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404
Bumped by Community user
added 1 character in body; edited title
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

Adding layer to geopackageGeoPackage

While running the following code

canvas = qgis.utils.iface.mapCanvas()
layer = canvas.currentLayer()
print(layer.name())
options = QgsVectorFileWriter.SaveVectorOptions()
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)
print(writer)

I getgot this error  :

(2, 'Opening of data source in update mode failed (OGR error: )')

The layer is created by with

layer = QgsVectorLayer("Point", 'layerName', "memory")

I tried to use this solution:  Adding layer to GeoPackage using PyQGIS butbut it is not working for me.

Adding layer to geopackage

While running the following

canvas = qgis.utils.iface.mapCanvas()
layer = canvas.currentLayer()
print(layer.name())
options = QgsVectorFileWriter.SaveVectorOptions()
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)
print(writer)

I get this error  :

(2, 'Opening of data source in update mode failed (OGR error: )')

The layer is created by with

layer = QgsVectorLayer("Point", 'layerName', "memory")

I tried to use this solution:  Adding layer to GeoPackage using PyQGIS but it is not working for me.

Adding layer to GeoPackage

While running the following code

canvas = qgis.utils.iface.mapCanvas()
layer = canvas.currentLayer()
print(layer.name())
options = QgsVectorFileWriter.SaveVectorOptions()
options.actionOnExistingFile = QgsVectorFileWriter.CreateOrOverwriteLayer

#options.layerName = "_".join(layer.name().split(' '))
writer = QgsVectorFileWriter.writeAsVectorFormat(layer, "C:/Users/ilyasse2.0/Documents/SQRLAND/hh.gpkg", options)
print(writer)

I got this error:

(2, 'Opening of data source in update mode failed (OGR error: )')

The layer is created by with

layer = QgsVectorLayer("Point", 'layerName', "memory")

I tried to use this solution: Adding layer to GeoPackage using PyQGIS but it is not working for me.

information from his comment was added to the question
Source Link
Loading
added 65 characters in body
Source Link
ThomasG77
  • 31.2k
  • 1
  • 55
  • 95
Loading
Source Link
Loading