Manage QGIS Projects in PostGIS
QGIS projects contain numerous elements, including layers and styles, print layout, custom tools, definitions for relations, default values, project variables, etc. The list goes on and on. All such information is saved to the QGS file, which is nothing more than an XML file. QGIS projects are often saved to the local filesystem, but they can also be saved to a PostgreSQL connection. In this section, you will learn how to manage projects with PostgreSQL. The following are some things to know about storing projects in PostgreSQL.
- qgis_projects table. Whenever a project is saved into a schema, QGIS creates a table in the target schema called “qgis_projects”. If a user creates projects in every schema, there will be a table called qgis_projects in every schema. In other words, the table only contains projects for the schema wherein it resides.
- Fields in the qgis_projects table. The qgis_projects table contains only three fields, namely name, metadata, and content.
- The name field contains the name of the project.
- The metadata field contains some metadata in JSON format.
The QGIS file is stored within the BYTEA field, which is a binary object data type (or BLOB).
Save QGIS Projects in PostgreSQL
Projects can be saved directly in a PostgreSQL database by following these steps:
- Click on Project on the top menu
- Click Save To > PostgreSQL.
- Select the desired output Connection and Schema
- Give the Project a name. The name can contain any characters, including uppercase letters and special characters.
- Press OK to save the project.
- Refresh the target schema and you will see the project stored in the database.

Rename a Project in PostgreSQL
A project stored in PostgreSQL can be renamed using the Attributes Table in QGIS.
- Load the qgis_projects table (make sure it’s from the correct schema).
- Open the table with the Attribute Table tool for the qgis_projects table.
- Toggle editing on and rename the value in the name field.
- Save edits and toggle editing off.
Delete a Project in PostgreSQL
Since QGIS projects reside in a single row in the qgis_projects table, it can be deleted by simply deleting the row.
- Load the qgis_projects table.
- Open the table with the Attribute Table tool for the qgis_projects table.
- Toggle editing on and delete the desired row.
- Save edits and toggle editing off.

Last Save Wins
If a user has read/write access to the qgis_projects table, they can modify and save the project. This can cause many problems within an enterprise environment if too many users have write permissions on the qgis_projects tables because the last save wins. That means that if two users, A and B, have the project open at the same time, the user who saves last will overwrite the one who saved previously. For example, if user A saved their work at 4:30PM and user B saved their work at 4:32PM, user B will completely overwrite work completed by user A. To avoid this issue, the following best practices should be followed:
- Store Templates. Store only template projects and maybe project-based QGS projects in the database.
- Limit the number of editors. Only allow a minimal number of users to modify the projects.
- Do not allow read-only users to edit projects. Grant read-only access to the qgis_projects tables to the vast majority of users in the enterprise. Do not freely hand out write access to everyone.
- Good communication. Good communication is recommended between all users who have editing permission on the project tables. If someone is going to modify a template, make sure no one else is doing the same at the same time. There is no way to lock access or even know who is editing a project simultaneously.
- Create copies for multiuser work. Save multiple versions of projects for different editors to avoid overwriting critical work.
How can we help?
Contact us today to schedule a free consultation with a member of our team.