2

Is it possible to use project variable in the PostgreSQL database connection in QGIS?

Usecase: Each user will set his/her db_user variable as part of the project. Once the project is shared among users, everybody will access the PostgreSQL database using assigned user.

Talking about project variables: I mean those, which are to be set in Project -> Properties and ɛ Variables

3
2

QGIS variables are effective after you open layers sources from QGIS project not before so it's not possible to provide connexion information here to my knowledge.

You should use PostgreSQL Service connection file instead. It avoids storing database informations within the project and instead use the configuration file to provide connection informations.

See official QGIS documentation https://docs.qgis.org/3.10/en/docs/user_manual/managing_data_source/opening_data.html#postgresql-service-connection-file and official PostgreSQL doc https://www.postgresql.org/docs/12/libpq-pgservice.html

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.