[QGIS-Developer] QgsProcessingParameterProviderConnection using cached database connections
Bo Victor Thomsen
bo.victor.thomsen at gmail.com
Thu Nov 30 08:51:02 PST 2023
Ok, I'm developing a processing plugin with two algorithms:
* The first algorithm: The user provides a number of informations
about a /new/ database. The algorithm creates the new database using
the information - and creates postgis extension, schemas and some
tables in the new database.
And lastly: it creates a database connection for the new database in
QGIS.
* The second algorithm: The user chooses a database connection from a
combobox created using the
/QgsProcessingParameterProviderConnection/ class. Finally the
algorithm creates and populates a number of tables using the chosen
connection
However: If you use the first algorithm to create the database and
immediately uses the second algorithm trying to populate the new
database, the connection is /not/ listed in the combobox.
I suspect it's because the /QgsProcessingParameterProviderConnection /is
using the cached list of connections when populating the dropdown list/
/
Somewhat like this (in Python):
metadata = QgsProviderRegistry.instance().providerMetadata('postgres')
pg_connections = metadata.connections(cached=True) # Read the cached
settings
I've had a similar problem in the past that was solved by changing the
"cached=True" to "cached=False" thereby forcing a reread of the
connection list.
If you restart QGIS after running algorithm no 1 and /then/ runs
algorithm no 2 it works like a charm.
My question: Is it possible to force
/QgsProcessingParameterProviderConnection /to re-read the list of
connections ? And, if possible, how ??
--
Med venlig hilsen / Best regards
Bo Victor Thomsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231130/cc360ede/attachment.htm>
More information about the QGIS-Developer
mailing list