1

I want to get the Geopackage file path where my layer is stored in.

Layer = QgsProject.instance().mapLayersByName('DAT')[0]
print(Layer.source())

But this only gives me the path with layer pointer:

/home/.../DAT.gpkg|layername=DAT

My approach was to do:

Layer = Layer.source().split("|")[0]

It works, but is there a better way?

Vince
  • 20,017
  • 15
  • 45
  • 64
Nunkuat
  • 485
  • 2
  • 11

0 Answers0