Class: QgsStoredQueryManager

A manager for stored SQL queries.

QgsStoredQueryManager is not usually directly created, instead use the instance accessible through QgsGui.storedQueryManager().

Added in version 3.44.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsStoredQueryManager

Base classes

QObject

Methods

allQueries

Returns details of all queries stored in the manager.

allQueryNames

Returns a list of the names of all stored queries for the specified backend.

query

Returns the query definition with matching name, from the specified backend.

removeQuery

Removes the stored query with matching name.

storeQuery

Saves a query to the manager.

Signals

queryAdded

Emitted when a query is added to the manager.

queryChanged

Emitted when an existing query is changed in the manager.

queryRemoved

Emitted when a query is removed from the manager.

class qgis.gui.QgsStoredQueryManager[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsStoredQueryManager, with the specified parent object.

Parameters:

parent (Optional[QObject] = None)

class QueryDetails[source]

Bases: object

Contains details about a stored query.

Added in version 3.44.

backend: Qgis.QueryStorageBackend

Storage backend.

definition: str

Query definition.

name: str

Name of the query.

allQueries(self) List[QgsStoredQueryManager.QueryDetails]

Returns details of all queries stored in the manager.

Queries will be sorted by name.

Return type:

List[QgsStoredQueryManager.QueryDetails]

allQueryNames(self, backend: Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile) List[str][source]

Returns a list of the names of all stored queries for the specified backend.

Parameters:

backend (Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile)

Return type:

List[str]

query(self, name: str | None, backend: Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile) str[source]

Returns the query definition with matching name, from the specified backend.

Parameters:
  • name (Optional[str])

  • backend (Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile)

Return type:

str

signal queryAdded(name: str, backend: Qgis.QueryStorageBackend)[source]

Emitted when a query is added to the manager.

Parameters:
signal queryChanged(name: str, backend: Qgis.QueryStorageBackend)[source]

Emitted when an existing query is changed in the manager.

Parameters:
signal queryRemoved(name: str, backend: Qgis.QueryStorageBackend)[source]

Emitted when a query is removed from the manager.

Parameters:
removeQuery(self, name: str | None, backend: Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile)[source]

Removes the stored query with matching name.

Parameters:
  • name (Optional[str]) – name of query to remove

  • backend (Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile) – storage backend for query

See also

queryRemoved()

storeQuery(self, name: str | None, query: str | None, backend: Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile)[source]

Saves a query to the manager.

If a query with the same name already exists it will be overwritten with the new definition.

Parameters:
  • name (Optional[str]) – user-set, unique name for the query.

  • query (Optional[str]) – query definition to store

  • backend (Qgis.QueryStorageBackend = Qgis.QueryStorageBackend.LocalProfile) – storage backend for query

See also

queryAdded()

See also

queryChanged()