I have created a centralized database using postgreSQL and created multiple users assigned with different roles i.e. SELECT, UPDATE, MODIFY and DELETE etc.




For user 'hasan' i have granted SELECT privileges on pois table which means he can only select and view the data. It works perfectly both in postgres and QGIS environment. The user can only run select query on the table and view the data in QGIS environment and cannot update or delete any record as i expected.

But the problem is in the QGIS environment, when the user right click on the table, he can easily export the table into a shapefile and then edit or update whatever he wants to do.

So my question is what can i do to stop the user from exporting the postgis table to a shapefile in QGIS?


Once you allow a user to select the data from your database there is no way to prevent them doing what they like with the data. If it is important to you that the user can only view and not edit the data you could consider using a WMS server (e.g GeoServer, MapServer) to render the data on your server and send only an image of the rendered data to the user.

  • Thank you for your quick response. I cannot do what you are suggesting because there are some users who will have the privileges to edit and update the data. – Shahzad Bacha Jul 28 '16 at 8:09
  • 4
    you can allow those users to access the data through a WFS – Ian Turton Jul 28 '16 at 8:10
  • WMS is perfect for this use case. – HeikkiVesanto Jul 29 '16 at 11:48

Some time ago I had the same challenge. What I did was remove the button export to the interface qgis to users who didn't have a permission.

How to? I leave some tips... QGis interface uses the system registry for show or not show some elements as buttons, windows, labels, etc.

You have a create a stand alone app that run at startup of QGIS and you connect to your database to read the user's permissions and finally edit the system registry. You can append the execute on "\bin\qgis.bat"

  1. In QGis go to Configuration > customization > enable custom for all.
  2. Edit the system registry: hkey_current_user/Software/QGIS/CUSTOMIZATION/QgsVectorLayerSaveAsDialogBase/buttonBox set to false.
  3. The results is the widget export shape without accept button. The button accept has removed
  • that's a good one but i cannot do that because my server runs on a public ip address and anyone who have username and password to my database can access it at home and do the same thing. – Shahzad Bacha Jul 29 '16 at 5:36
  • You could configure remote access from pg_hba.conf file and only allow access from place work(?) – d345k0 Jul 29 '16 at 14:37

I wonder why you bother with this. Even if anyone loads your data as shapefile he/she is not able to modify your primary data-source (the database), it is just a copy. He/she can do everything of his premises with this data once it is fully copied to the users computer- no way to limit this, but why should you?

Even if there were a way in QGIS, a user could easily export to shapefile using any different converter-tool (e.g. pgsql2shp).

Having said this all you really have to care about is that your database-roles are configured appropriately enabling only those users update-operations you want. Viewing and copying however is a quite harmless operation you shouldn´t bother.

From a database point of view there´s nothing you could do against this. If you want to avoid users to copy your data you should make legal constraints or license-information to it. E.g. you could provide the data for viewing as WMS and for modifying as WFS. So anyone who should be able to modify your data has another license-level than those who can simply view it.

  • 1
    So it's okay to have users copying data and making their own changes that are never incorporated into the main database? That is a YUGE problem I encounter on an almost daily basis. – DenaliHardtail Jul 28 '16 at 16:29
  • my company do not allow anyone to copy the data because its not for free – Shahzad Bacha Jul 29 '16 at 5:25
  • But you can´t hinder anyone copying it if he can view the data. Think of taking a screenshot from a website. If you can access the site you can also copy its content, no way to avoid this. SQL - and this is what users may use when accessing your data, not neccessarily QGIS - does not make any difference on viewing data and copying it. – HimBromBeere Jul 29 '16 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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