Class: QgsConnectionRegistry

A registry for saved data provider connections, allowing retrieval of saved connections by name and provider type.

QgsConnectionRegistry is not usually directly created, but rather accessed through QgsApplication.connectionRegistry().

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.core.QgsConnectionRegistry

Base classes

QObject

Methods

createConnection

Creates a new connection by loading the connection with the given id from the settings.

class qgis.core.QgsConnectionRegistry[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsConnectionRegistry.

Parameters:

parent (Optional[QObject] = None)

createConnection(self, name: str | None) QgsAbstractProviderConnection | None[source]

Creates a new connection by loading the connection with the given id from the settings.

The id string must be of the format “provider://connection_name”, e.g. “postgres://my_connection” for the PostgreSQL connection saved as “my_connection”.

Ownership is transferred to the caller.

Raises:

QgsProviderConnectionException

Parameters:

name (Optional[str])

Return type:

Optional[QgsAbstractProviderConnection]