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
providerandconnectionname.The optional
schemaargument can be used to restrict the tables to those from a specific schema.Warning
The
providermust support the connection API methods in itsQgsProviderMetadataimplementation 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
schemaargument can be used to restrict the tables to those from a specific schema.Ownership of
connectionis transferred to the model.- Parameters:
 connection (Optional[QgsAbstractDatabaseProviderConnection])
schema (Optional[str] = '')
parent (Optional[QObject] = None)
- class CustomRole(*values)¶
 Bases:
IntEnumCustom model roles.
Note
Prior to QGIS 3.36 this was available as QgsDatabaseTableModel.Role
Added in version 3.36.
TableName: Table nameAvailable as
QgsDatabaseTableModel.RoleTableNamein older QGIS releases.Schema: Table schemaAvailable as
QgsDatabaseTableModel.RoleSchemain older QGIS releases.TableFlags: Table flags roleAvailable as
QgsDatabaseTableModel.RoleTableFlagsin older QGIS releases.Comment: Comment roleAvailable as
QgsDatabaseTableModel.RoleCommentin older QGIS releases.CustomInfo: Custom info variant map roleAvailable as
QgsDatabaseTableModel.RoleCustomInfoin older QGIS releases.WkbType: WKB type for primary (first) geometry column in tableAvailable as
QgsDatabaseTableModel.RoleWkbTypein older QGIS releases.Crs: CRS for primary (first) geometry column in tableAvailable as
QgsDatabaseTableModel.RoleCrsin older QGIS releases.Empty: Entry is an empty entryAvailable as
QgsDatabaseTableModel.RoleEmptyin older QGIS releases.
- Role¶
 alias of
CustomRole
- allowEmptyTable(self) bool[source]¶
 Returns
Trueif the model allows the empty table (“not set”) choice.See also
- Return type:
 bool