[QGIS-Developer] Function to generate uri from settings in QGIS
Bo Victor Thomsen
bo.victor.thomsen at gmail.com
Sat Jan 9 05:04:09 PST 2021
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, geometry column and optionally
# subset (WHERE clause)
uri.setDataSource("public", "roads", "the_geom", "cityid = 2643")
vlayer = QgsVectorLayer(uri.uri(False), "layer name you like", "postgres")
But I would like to use information from a already defined Datasource
connection from the Datamanager dialog.
I suspect, that there must be a
"QgsSettingsConvertToUri_or_whatever_it_is_called()" function that uses
a QGS settings address (ex. like "/PostgreSQL/connections/MyDatabase"
for a Postgresql database connection) as input and automatically
convert the settings values to a URI string.
Is there anyone, that can point me in the right direction ?
--
Med venlig hilsen / Kind regards
Bo Victor Thomsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210109/54a2756a/attachment.html>
More information about the QGIS-Developer
mailing list