I have a table loaded in QGIS from spatialite DB. When i see the layer properties it is dbname='/home/farook/Spatialite/Cities.sqlite' table="cities" sql=. Now i want the dbname alone (i.e) the entire path '/home/farook/Spatialite/Cities.sqlite' for whatever layer loaded inside QGIS dynamically using PyQGIS. Is there any options for the same?
Answer
These two code statements will provide the table path to the db name:
print iface.activeLayer().dataProvider().dataSourceUri().split('|')[0]
or
print lyr.dataProvider().dataSourceUri().split('|')[0]
No comments:
Post a Comment