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?
>>>layerProvider = layer.dataProvider()
>>>FilePath = layerProvider.dataSourceUri()
>>>FilePath = os.path.dirname(unicode(FilePath))
dp = my_lyr.dataProvider() print(dp.uri())
.