The connection API is indeed convenient for that :
metadata = QgsProviderRegistry.instance().providerMetadata('postgres')
connection = metadata.findConnection("the postgis connection name")
uri = QgsDataSourceUri(connection.uri())
Le sam. 9 janv. 2021 à 22:36, Alessandro Pasotti a
écrit :
> Hi
Pedro Venâncio-2 wrote
> I believe 3.10.13-2 also fixes this issue.
>
> Do you confirm?
Hi Pedro,
yes, I can confirm that both 3.16.2-2 and 3.10.13-2 standalone installers
ship QGIS with GRASS 7.8.5 and the issue is now fixed for both thanks to
Jürgen E. Fischer.
Regards.
Andrea
--
Sent from
Hi Bo,
you may have a look to
https://qgis.org/pyqgis/master/core/QgsProviderRegistry.html?highlight=decodeuri#qgis.core.QgsProviderRegistry.decodeUri
and encodeUri.
Or better: the connections API
https://qgis.org/pyqgis/master/core/QgsAbstractProviderConnection.html
On Sat, Jan 9, 2021 at 2:0
Ok, this has me stumped.
I know, that I can generate a database URI like this (example from
cookbook):
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection("localhost", "5432", "dbname", "johny", "xxx")
# set database schema, table name,