Class: QgsDatabaseSchemaModel

A model containing schemas from a database connection.

This class does not automatically subscribe to database updates. Schemas are queried from the database initially upon model construction. In order to update the listed schemas, QgsDatabaseSchemaModel.refresh() must be manually called.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.core.QgsDatabaseSchemaModel

Base classes

QAbstractItemModel

QObject

Enums

CustomRole

Custom model roles.

Role

alias of CustomRole

Methods

allowEmptySchema

Returns True if the model allows the empty schema ("not set") choice.

refresh

Refreshes the schema list by querying the underlying connection.

setAllowEmptySchema

Sets whether an optional empty schema ("not set") option is present in the model.

class qgis.core.QgsDatabaseSchemaModel[source]

Bases: QAbstractItemModel

__init__(provider: str | None, connection: str | None, parent: QObject | None = None)

Constructor for QgsDatabaseSchemaModel, for the specified provider and connection name.

Warning

The provider must support the connection API methods in its QgsProviderMetadata implementation in order for the model to work correctly.

Parameters:
  • provider (Optional[str])

  • connection (Optional[str])

  • parent (Optional[QObject] = None)

__init__(connection: QgsAbstractDatabaseProviderConnection | None, parent: QObject | None = None)

Constructor for QgsDatabaseSchemaModel, for the specified connection.

Ownership of connection is transferred to the model.

Parameters:
class CustomRole(*values)

Bases: IntEnum

Custom model roles.

Note

Prior to QGIS 3.36 this was available as QgsDatabaseSchemaModel.Role

Added in version 3.36.

  • Empty: Entry is an empty entry

    Available as QgsDatabaseSchemaModel.RoleEmpty in older QGIS releases.

Role

alias of CustomRole

allowEmptySchema(self) bool[source]

Returns True if the model allows the empty schema (“not set”) choice.

Return type:

bool

refresh(self)[source]

Refreshes the schema list by querying the underlying connection.

setAllowEmptySchema(self, allowEmpty: bool)[source]

Sets whether an optional empty schema (“not set”) option is present in the model.

Parameters:

allowEmpty (bool)