I am trying to open a QGIS project that is saved to the database (Project -> Save to -> PostgreSQL) by means of Python script.

I find a similar way to open project which is saved to the desktop using QgsProject.instance().read(filename).

Can anyone guide me a similar way to open from database?

  • In qgis.org/pyqgis/3.0/core/Project/… I am not able to find any relevant references to postgresql, so it may look as if it is not directly possible through python, but there are smart people around here, somebody may know something... Commented Mar 20, 2020 at 12:55

1 Answer 1


You can load a project from a database storage (e.g., PostgreSQL or GeoPackage) in this way:


Where uri is the file name of the project, which you could get from:


Since we are dealing with projects stored in databases, the file name is actually a uri.

Sample uris:

  • Project in a PostgreSQL database:

  • Project in a GeoPackage database:




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.