5

EDIT: added further explanation with pics

Is it possible to populate an input field (enum etc.), with options that are obtained from postgresql database? Similar to how you can already select database tables from a dropdown, would it be possible to implement a dropdown with, for example, existing database users ?

I found no way to create input options as a result of an sql expression.

example, builtin support for listing available schemas,

I would like the same for users, etc. enter image description here

1 Answer 1

2

You can do that with the form settings in Qgis 3

go in layer => properties => form

then choose "drag and drop designer"

then you can make up your own form. If you have a field based on a postgres enum, you can pick this field (column) and use enumeration option

Qgis will automatically find the enum values and fill a Qt combobox and display it when you want to edit a given entity.

This is a broader then enum , you can do a lot of things with custom form.

exemple below (sorry for french Qgis) the field type_cross_section_up is an enum with multiple choices and you see that Qgis display the enum's possibilities in the combo

enter image description here

enter image description here

2
  • Thx for answering, although its not what i meant. I would need the options that are queried from database, inside the dropdown inside the model (put 'Model designer in title, but should have also specified in body). EDIT: added further explanation with pics
    – Hajc
    Sep 24, 2021 at 6:05
  • your question doesn't seem to referer to Qgis modeler to me. Qgis modeler is an UI to chain geotraitement not connecting to Postgres database. If you want to change this database connection interface you can try to find this form in Qgis codebase and update it to be able to select a given user but it's not a native option indeed. you can also request this development in the Qgis project (and fund it?). Sep 25, 2021 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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