[QGIS-Developer] Pass a custom parameters at session level when connect to postgreSQL with QgsDataSourceURI

Yoann Lecomte yoann_lecomte31 at orange.fr
Tue Mar 27 00:36:51 PDT 2018


Hi every one,

I'm developping a QGIS 2.18 plugin that works with a multiuser 
postgreSQL database.

I need to create a connection with postgreSQL/Postgis and pass some 
custom parameters to the session (SET SESSION variable) to handle some 
row-level access (postgres 9.5 - Create policy). For that I try to use 
QgsDataSourceURI from 2.18 pyqgis API. But I can't figure out how to 
pass custom parameters at the session level with this tool. I need that 
to add layers to QGIS that would be automatically filtered by this 
custom parameters which works with my postgreSQL policy.

See for a more detailled explanation of the problem, I have this related 
question on GIS Stack Exchange:

https://gis.stackexchange.com/questions/276292/loading-postgres-layer-with-session-parameter-set-using-pyqgis

Thank's in advance for answers!
-- 
sign-pro

*Yoann Lecomte*
/Développeur Géomaticien/
Tél: 06.07.65.70.47
<https://www.linkedin.com/in/yoannlecomte/> 
<https://www.github.com/yolecomte/>

Pensez environnement, n'imprimez ce mail que si nécessaire

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180327/58521905/attachment.html>


More information about the QGIS-Developer mailing list