Subgroup: Auxiliary

Class: QgsAuxiliaryStorage

class qgis.core.QgsAuxiliaryStorage

Bases: sip.wrapper

Class providing some utility methods to manage auxiliary storage.

New in version 3.0: Methods

createAuxiliaryLayer Creates an auxiliary layer for a vector layer.
currentFileName Returns the path of the current database used.
deleteTable Removes a table from the auxiliary storage.
duplicateTable Duplicates a table and its content.
extension Returns the extension used for auxiliary databases.
fileName Returns the target filename of the database.
isValid Returns the status of the auxiliary storage currently defined.
save Saves the current database.
saveAs Saves the current database to a new path.

Attributes

createAuxiliaryLayer(self, field: QgsField, layer: QgsVectorLayer) → QgsAuxiliaryLayer

Creates an auxiliary layer for a vector layer. A new table is created if necessary. The primary key to use to construct the auxiliary layer is given in parameter.

Parameters:
  • field – The primary key to join
  • layer – The vector layer for which the auxiliary layer has to be created
Returns:

A new auxiliary layer or a None if an error happened.

currentFileName(self) → str

Returns the path of the current database used. It may be different from the target filename if the auxiliary storage is opened in copy mode.

deleteTable(uri: QgsDataSourceUri) → bool

Removes a table from the auxiliary storage.

Parameters:uri – The uri of the table to remove
Returns:true if the table is well deleted, false otherwise
duplicateTable(uri: QgsDataSourceUri, newTable: str) → bool

Duplicates a table and its content.

Parameters:
  • uri – The uri of the table to duplicate
  • newTable – The name of the new table
Returns:

true if the table is well duplicated, false otherwise

extension() → str

Returns the extension used for auxiliary databases.

fileName(self) → str

Returns the target filename of the database.

isValid(self) → bool

Returns the status of the auxiliary storage currently defined.

Returns:true if the auxiliary storage is valid, false otherwise
save(self) → bool

Saves the current database.

Returns:true if everything is saved, false otherwise
saveAs(self, filename: str) → bool

Saves the current database to a new path.

Returns:true if everything is saved, false otherwise

saveAs(self, project: QgsProject) -> bool Saves the current database to a new path for a specific project. Actually, the current filename of the project is used to deduce the path of the database to save.

Returns:true if everything is saved, false otherwise