Re: [QGIS-Developer] Function to generate uri from settings in QGIS

2021-01-11 Thread Bo Victor Thomsen
Multiple thanks to both Alessandro and Etienne for helping me with this question. I owe you both a large cold beer (each !) next time we meet. Med venlig hilsen / Kind regards Bo Victor Thomsen Den 10-01-2021 kl. 04:10 skrev Etienne Trimaille: The connection API is indeed convenient for that

Re: [QGIS-Developer] Function to generate uri from settings in QGIS

2021-01-09 Thread Etienne Trimaille
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

Re: [QGIS-Developer] Function to generate uri from settings in QGIS

2021-01-09 Thread Alessandro Pasotti
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

[QGIS-Developer] Function to generate uri from settings in QGIS

2021-01-09 Thread Bo Victor Thomsen
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