[QGIS-Developer] Access DB manager connection details in a python plugins

Florian El Ahdab felahdab at gmail.com
Fri Jul 23 08:48:21 PDT 2021


Hi

Thanks.
Your code snippet is what I was looking for. I want to re-use the database
connection settings from my plugin.

Regards.
Florian.

Le ven. 23 juil. 2021 à 08:32, Etienne Trimaille <
etienne.trimaille at gmail.com> a écrit :

> Can you clarify what you need from DBManager?
> Widgets ? Features ?
> Or do you mean to be able to list DB connections and launch SQL queries ?
>
> You should avoid importing code from the DbManager plugin as it is removed
> step by step.
> Use the database API :
> https://qgis.org/api/classQgsAbstractDatabaseProviderConnection.html
>
> metadata = QgsProviderRegistry.instance().providerMetadata('postgres')
> connection = metadata.findConnection("name_of_connection)
> connection.executeSql("SELECT ....")
>
>
>
> Le jeu. 22 juil. 2021 à 22:09, Florian El Ahdab <felahdab at gmail.com> a
> écrit :
>
>> Hi.
>>
>> I would like to take advantage of the db manager from a python plugin.
>> That would allow me to avoid handling the database configuration myself and
>> would make the overall ui more consistent for the user.
>>
>> I can't find any relevant reference to do that.
>>
>> Has anyone achieved anything like that ?
>>
>> Regards.
>> Florian.
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210723/bf1b5449/attachment-0001.html>


More information about the QGIS-Developer mailing list