Class: QgsDatabaseTableModel¶
A model containing tables from a database connection.
This class does not automatically subscribe to database updates. Tables
are queried from the database initially upon model construction. In
order to update the listed tbales,
QgsDatabaseTableModel.refresh()
must be manually called.
Added in version 3.14.
Class Hierarchy¶
Base classes¶
Enums
Custom model roles. |
|
alias of |
Methods
Returns |
|
Refreshes the table list by querying the underlying connection. |
|
Sets whether an optional empty table ("not set") option is present in the model. |
- class qgis.core.QgsDatabaseTableModel[source]¶
Bases:
QAbstractItemModel
- __init__(provider: str | None, connection: str | None, schema: str | None = '', parent: QObject | None = None)
Constructor for QgsDatabaseTableModel, for the specified
provider
andconnection
name.The optional
schema
argument can be used to restrict the tables to those from a specific schema.Warning
The
provider
must support the connection API methods in itsQgsProviderMetadata
implementation in order for the model to work correctly.- Parameters:
provider (Optional[str])
connection (Optional[str])
schema (Optional[str] = '')
parent (Optional[QObject] = None)
- __init__(connection: QgsAbstractDatabaseProviderConnection | None, schema: str | None = '', parent: QObject | None = None)
Constructor for QgsDatabaseTableModel, for the specified
connection
.The optional
schema
argument can be used to restrict the tables to those from a specific schema.Ownership of
connection
is transferred to the model.- Parameters:
connection (Optional[QgsAbstractDatabaseProviderConnection])
schema (Optional[str] = '')
parent (Optional[QObject] = None)
- class CustomRole(*values)¶
Bases:
IntEnum
Custom model roles.
Note
Prior to QGIS 3.36 this was available as QgsDatabaseTableModel.Role
Added in version 3.36.
TableName
: Table nameAvailable as
QgsDatabaseTableModel.RoleTableName
in older QGIS releases.Schema
: Table schemaAvailable as
QgsDatabaseTableModel.RoleSchema
in older QGIS releases.TableFlags
: Table flags roleAvailable as
QgsDatabaseTableModel.RoleTableFlags
in older QGIS releases.Comment
: Comment roleAvailable as
QgsDatabaseTableModel.RoleComment
in older QGIS releases.CustomInfo
: Custom info variant map roleAvailable as
QgsDatabaseTableModel.RoleCustomInfo
in older QGIS releases.WkbType
: WKB type for primary (first) geometry column in tableAvailable as
QgsDatabaseTableModel.RoleWkbType
in older QGIS releases.Crs
: CRS for primary (first) geometry column in tableAvailable as
QgsDatabaseTableModel.RoleCrs
in older QGIS releases.Empty
: Entry is an empty entryAvailable as
QgsDatabaseTableModel.RoleEmpty
in older QGIS releases.
- Role¶
alias of
CustomRole
- allowEmptyTable(self) bool [source]¶
Returns
True
if the model allows the empty table (“not set”) choice.See also
- Return type:
bool