Feature request #16539

option to skip layer table panel if adding a geopackage to the project using the api

Added by Paul van Genuchten about 7 years ago. Updated almost 7 years ago.

Category:Data Provider
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:24445


Currently if you use the api from a python plugin to add a geopackage to the project (as used in https://github.com/pka/qgpkg) a popup is displayed giving the option to select tables to add to the project. This is undesirable, since the plugin at that point already knows which layers it wants to add.

I suggest to extend the geopackage api to expose in the addVectorLayer method an optional parameter "tables" that, if filled, will override the popup and add the selected tables directly.


QGIS uses ogr to open a geopackage
the plugin is passing the file to GDAL/OGR, who is doing all the work
This is how a file can be opened
.addVectorLayer(gpkg_path, "", "ogr")
it calls a generic vector provider, and passes the OGR driver
for most cases, when you call this function, you get back one layer
But in the case of geopackage you get multiple layers; this is the issue


#1 Updated by Alexander Bruy about 7 years ago

  • Tracker changed from Bug report to Feature request

#2 Updated by Paul van Genuchten almost 7 years ago

  • Status changed from Open to Closed

hint from @pkalberer
Apparantly this is possible:
.addVectorLayer(gpkg_path + "|layername=" + layername, title, "ogr")
so to add the layername concatenated with |

Also available in: Atom PDF