[gdal-dev] Setting roles in PostGIS connection

Even Rouault even.rouault at spatialys.com
Fri Jul 2 07:25:49 PDT 2021


Pekka,

I suspect you use "ogr2ogr -f PostgreSQL PG:....."

If you use rather "ogr2ogr -update PG:...." you should be able to use 
-doo (not sure the SET ROLE will work properly in that context though)

Even

Le 02/07/2021 à 08:52, Pekka Sarkola a écrit :
> Hi!
>
> We have a PostGIS database with login roles and group roles (like 
> "admins", "editors" and "viewers"). We have defined that only "admins" 
> can create new schemas and tables (among other privileges). My problem 
> is that I'd like to use ogr2ogr to bulk load some data to a PostGIS 
> database using ogr2ogr with a certain login role with "admins" role.
>
> It seems that it is not possible to define roles in PostgreSQL 
> connection parameters (my first try) or in PostgreSQL driver options.
> I tried to use PREDUDE_STATEMENTS like: "-doo "PRELUDE_STATEMENTS=SET 
> ROLE admins", but got warning "Warning 1: -doo ignored when creating 
> the output datasource."
>
> Any solutions or suggestions?
>
> There is also similar case in QGIS: Supporting "set role" when 
> connecting to a postgres database - 
> https://github.com/qgis/QGIS/issues/42763 
> <https://github.com/qgis/QGIS/issues/42763>
>
> Versions: GDAL 3.0.4, released 2020/01/28, PostgreSQL 12.7, PostGIS 3.1
>
> Rgs,
>
> Pekka
>
> Pekka Sarkola
> Gispo Oy
> pekka.sarkola at gispo.fi <mailto:pekka.sarkola at gispo.fi>- GSM +358 
> 40 725 2042
> www.gispo.fi <http://www.gispo.fi/>– www.paikkatieto.com 
> <http://www.paikkatieto.com/>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210702/afd6ec35/attachment.html>


More information about the gdal-dev mailing list