2

How it is possible save qgis project to GeoPackage in PyQGIS?

enter image description here

the image is user interface but I need in code

Germán Carrillo
  • 36,307
  • 5
  • 123
  • 178

1 Answers1

5

You need to construct a URI like this:

uri = 'geopackage:/path/to/db.gpkg?projectName=my_gpgk_project'

And then use it to save the project, in this way:

QgsProject.instance().write(uri)
Germán Carrillo
  • 36,307
  • 5
  • 123
  • 178
  • Thanks that's worked, and do you have any idea where can I found documentation about this ? – Angel Rene Herrera Calzada Jul 21 '20 at 15:30
  • 1
    Actually, not. But, GIS.SE is also a source of documentation. In fact, many answers provided here are later copied to official documentation sources. Of course, you always have the source code available, which, when programming, may be seen as the best documentation source (think about code comments and unit tests) at all. – Germán Carrillo Jul 21 '20 at 15:41