Class: QgsAbstractProviderConnection

An interface for data provider connections.

Connections objects can be constructed loading them from the connections stored in the settings by passing the connection name. A new connection object can also be created by passing a data source URI in the constructor.

Provider metadata keep a cache of the existing connections, to manage stored connections it is recommendend to call metadata methods instead of loading and storing the connections directly.

Concrete classes must implement methods to retrieve, save and remove connections from the settings.

Added in version 3.10.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: remove(), store()

Class Hierarchy

Inheritance diagram of qgis.core.QgsAbstractProviderConnection

Subclasses

QgsAbstractDatabaseProviderConnection

Provides common functionality for database based connections.

QgsStacConnection

Represents connections to STAC catalogs.

Abstract Methods

remove

Deletes the connection from the settings.

store

Stores the connection in the settings.

Methods

configuration

Returns the connection configuration parameters

setConfiguration

Sets the connection configuration

setUri

Sets the connection data source URI to uri

uri

Returns the connection data source URI string representation

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsAbstractProviderConnection. See the FAQ for more details.

icon

Returns an icon representing the connection.

class qgis.core.QgsAbstractProviderConnection[source]

Bases: object

__init__(name: str | None)

Creates a new connection with name by reading its configuration from the settings. If a connection with this name cannot be found, an empty connection will be returned.

Parameters:

name (Optional[str])

__init__(uri: str | None, configuration: Dict[str, Any])

Creates a new connection from the given uri and configuration. The connection is not automatically stored in the settings.

See also

store()

Parameters:
  • uri (Optional[str])

  • configuration (Dict[str, Any])

__init__(a0: QgsAbstractProviderConnection)
Parameters:

a0 (QgsAbstractProviderConnection)

configuration(self) Dict[str, Any][source]

Returns the connection configuration parameters

Return type:

Dict[str, Any]

virtual icon(self) QIcon[source]

Returns an icon representing the connection.

Return type:

QIcon

abstract remove(self, name: str | None)[source]

Deletes the connection from the settings.

Parameters:

name (Optional[str])

setConfiguration(self, configuration: Dict[str, Any])[source]

Sets the connection configuration

Parameters:

configuration (Dict[str, Any])

setUri(self, uri: str | None)[source]

Sets the connection data source URI to uri

Parameters:

uri (Optional[str])

abstract store(self, name: str | None)[source]

Stores the connection in the settings.

Parameters:

name (Optional[str]) – the name under which the connection will be stored

uri(self) str[source]

Returns the connection data source URI string representation

Return type:

str