Wednesday 14 June 2017

PostGIS/QGIS and granting permissions


I've got a PostGIS databases, with lots of schemas. I can easily create a new user that will allow them to update and delete features. However when I get the user to create a new feature I get the following error in QGIS:-


  PostGIS error while adding features: ERROR:  new row for relation "conservation_areas" violates check constraint "enforce_geotype_geom

I've used the following SQL to GRANT the user (anne) privilages that will allow her to update and delete, but I guess its the insert bit that is letting me down.


GRANT ALL ON SCHEMA conservation TO anne;
GRANT SELECT ON ALL TABLES IN SCHEMA conservation TO anne;
GRANT UPDATE ON conservation.conservation_areas_gid_seq To anne;
GRANT UPDATE ON conservation.conservation_areas TO anne;


The postgres user has no such issues when edited data, therefore I'm missing something somewhere when i'm granting the user permissions. Is there a simple SQL that will allow a user to do everything that the Postgres user can do but to a specific tables (and not all tables) within a schema?


Med



Answer



With a slight tweak to Mapperz suggested SQL statement, the below SQL allows my user (anne) in QGIS to save a new map feature to my table.


GRANT ALL ON SCHEMA conservation TO anne;
GRANT SELECT ON ALL TABLES IN SCHEMA conservation TO anne;
GRANT ALL PRIVILEGES ON conservation.conservation_areas TO anne;
GRANT UPDATE ON conservation.conservation_areas_gid_seq TO anne;


Thanks all for your posts.


Med


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...