QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
QgsAbstractDatabaseProviderConnection Class Referenceabstract

The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connections. More...

#include <qgsabstractdatabaseproviderconnection.h>

Inheritance diagram for QgsAbstractDatabaseProviderConnection:
Inheritance graph
[legend]

Classes

struct  QueryResult
 The QueryResult class represents the result of a query executed by execSql() More...
 
struct  SpatialIndexOptions
 The SpatialIndexOptions contains extra options relating to spatial index creation. More...
 
struct  SqlVectorLayerOptions
 The SqlVectorLayerOptions stores all information required to create a SQL (query) layer. More...
 
struct  TableProperty
 The TableProperty class represents a database table or view. More...
 

Public Types

typedef QFlags< CapabilityCapabilities
 
enum  Capability {
  CreateVectorTable = 1 << 1 , DropRasterTable = 1 << 2 , DropVectorTable = 1 << 3 , RenameVectorTable = 1 << 4 ,
  RenameRasterTable = 1 << 5 , CreateSchema = 1 << 6 , DropSchema = 1 << 7 , RenameSchema = 1 << 8 ,
  ExecuteSql = 1 << 9 , Vacuum = 1 << 10 , Tables = 1 << 11 , Schemas = 1 << 12 ,
  SqlLayers = 1 << 13 , TableExists = 1 << 14 , Spatial = 1 << 15 , CreateSpatialIndex = 1 << 16 ,
  SpatialIndexExists = 1 << 17 , DeleteSpatialIndex = 1 << 18 , DeleteField = 1 << 19 , DeleteFieldCascade = 1 << 20 ,
  AddField = 1 << 21 , ListFieldDomains = 1 << 22 , RetrieveFieldDomain = 1 << 23 , SetFieldDomain = 1 << 24 ,
  AddFieldDomain = 1 << 25 , RenameField = 1 << 26 , RetrieveRelationships = 1 << 27 , AddRelationship = 1 << 28 ,
  UpdateRelationship = 1 << 29 , DeleteRelationship = 1 << 30
}
 The Capability enum represents the operations supported by the connection. More...
 
typedef QFlags< GeometryColumnCapabilityGeometryColumnCapabilities
 
enum  GeometryColumnCapability {
  Z = 1 << 1 , M = 1 << 2 , SinglePart = 1 << 3 , Curves = 1 << 4 ,
  SinglePoint = 1 << 5 , SingleLineString = 1 << 6 , SinglePolygon = 1 << 7 , PolyhedralSurfaces = 1 << 8
}
 The GeometryColumnCapability enum represents the geometry column features supported by the connection. More...
 
enum class  TableFlag : int {
  Aspatial = 1 << 1 , Vector = 1 << 2 , Raster = 1 << 3 , View = 1 << 4 ,
  MaterializedView = 1 << 5 , Foreign = 1 << 6 , IncludeSystemTables = 1 << 7
}
 Flags for table properties. More...
 
typedef QFlags< TableFlagTableFlags
 

Public Member Functions

 QgsAbstractDatabaseProviderConnection (const QString &name)
 Creates a new connection with name by reading its configuration from the settings.
 
 QgsAbstractDatabaseProviderConnection (const QString &uri, const QVariantMap &configuration)
 Creates a new connection from the given uri and configuration.
 
virtual void addField (const QgsField &field, const QString &schema, const QString &tableName) const
 Adds a field.
 
virtual void addFieldDomain (const QgsFieldDomain &domain, const QString &schema) const
 Adds a new field domain to the database.
 
virtual void addRelationship (const QgsWeakRelation &relationship) const
 Adds a new field relationship to the database.
 
Capabilities capabilities () const
 Returns connection capabilities.
 
Qgis::DatabaseProviderConnectionCapabilities2 capabilities2 () const
 Returns extended connection capabilities.
 
virtual void createSchema (const QString &name) const
 Creates a new schema with the specified name.
 
virtual void createSpatialIndex (const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options=QgsAbstractDatabaseProviderConnection::SpatialIndexOptions()) const
 Creates a spatial index for the database table with given schema and name (schema is ignored if not supported by the backend).
 
virtual QgsVectorLayercreateSqlVectorLayer (const SqlVectorLayerOptions &options) const
 Creates and returns a (possibly invalid) vector layer based on the sql statement and optional options.
 
virtual void createVectorTable (const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap< QString, QVariant > *options) const
 Creates an empty table with name in the given schema (schema is ignored if not supported by the backend).
 
virtual void deleteField (const QString &fieldName, const QString &schema, const QString &tableName, bool force=false) const
 Deletes the field with the specified name.
 
virtual void deleteRelationship (const QgsWeakRelation &relationship) const
 Deletes an existing relationship in the database.
 
virtual void deleteSpatialIndex (const QString &schema, const QString &name, const QString &geometryColumn) const
 Deletes the existing spatial index for the database table with given schema, name and geometryColumn (schema and geometryColumn are ignored if not supported by the backend).
 
virtual void dropRasterTable (const QString &schema, const QString &name) const
 Drops a raster table with given schema (schema is ignored if not supported by the backend) and name.
 
virtual void dropSchema (const QString &name, bool force=false) const
 Drops an entire schema with the specified name.
 
virtual void dropVectorTable (const QString &schema, const QString &name) const
 Drops a vector (or aspatial) table with given schema (schema is ignored if not supported by the backend) and name.
 
virtual QueryResult execSql (const QString &sql, QgsFeedback *feedback=nullptr) const
 Executes raw sql and returns the (possibly empty) query results, optionally feedback can be provided.
 
virtual QList< QList< QVariant > > executeSql (const QString &sql, QgsFeedback *feedback=nullptr) const
 Executes raw sql and returns the (possibly empty) list of results in a multi-dimensional array, optionally feedback can be provided.
 
virtual QgsFieldDomainfieldDomain (const QString &name) const
 Returns the field domain with the specified name from the provider.
 
virtual QStringList fieldDomainNames () const
 Returns a list of field domain names present on the provider.
 
virtual QgsFields fields (const QString &schema, const QString &table, QgsFeedback *feedback=nullptr) const
 Returns the fields of a table and schema.
 
virtual GeometryColumnCapabilities geometryColumnCapabilities ()
 Returns connection geometry column capabilities (Z, M, SinglePart, Curves).
 
virtual QSet< QString > illegalFieldNames () const
 Returns a list of field names which are considered illegal by the connection and should not be used when creating or altering fields.
 
virtual QList< QgsVectorDataProvider::NativeTypenativeTypes () const =0
 Returns a list of native types supported by the connection.
 
QString providerKey () const
 Returns the provider key.
 
virtual QgsProviderSqlQueryBuilderqueryBuilder () const
 Returns a SQL query builder for the connection, which provides an interface for provider-specific creation of SQL queries.
 
virtual QStringList relatedTableTypes () const
 Returns a list of the related table types supported by the database format.
 
virtual QList< QgsWeakRelationrelationships (const QString &schema=QString(), const QString &tableName=QString()) const
 Returns a list of relationships detected in the database.
 
virtual void renameField (const QString &schema, const QString &tableName, const QString &name, const QString &newName) const
 Renames an existing field.
 
virtual void renameRasterTable (const QString &schema, const QString &name, const QString &newName) const
 Renames a raster table with given schema (schema is ignored if not supported by the backend) and name.
 
virtual void renameSchema (const QString &name, const QString &newName) const
 Renames a schema with the specified name.
 
virtual void renameVectorTable (const QString &schema, const QString &name, const QString &newName) const
 Renames a vector or aspatial table with given schema (schema is ignored if not supported by the backend) and name.
 
virtual QStringList schemas () const
 Returns information about the existing schemas.
 
virtual QList< QgsLayerMetadataProviderResultsearchLayerMetadata (const QgsMetadataSearchContext &searchContext, const QString &searchString=QString(), const QgsRectangle &geographicExtent=QgsRectangle(), QgsFeedback *feedback=nullptr) const
 Search the stored layer metadata in the connection, optionally limiting the search to the metadata identifier, title, abstract, keywords and categories.
 
virtual void setFieldAlias (const QString &fieldName, const QString &schema, const QString &tableName, const QString &alias) const
 Sets the alias for the existing field with the specified name.
 
virtual void setFieldComment (const QString &fieldName, const QString &schema, const QString &tableName, const QString &comment) const
 Sets the comment for the existing field with the specified name.
 
virtual void setFieldDomainName (const QString &fieldName, const QString &schema, const QString &tableName, const QString &domainName) const
 Sets the field domain name for the existing field with the specified name.
 
virtual bool spatialIndexExists (const QString &schema, const QString &name, const QString &geometryColumn) const
 Determines whether a spatial index exists for the database table with given schema, name and geometryColumn (schema and geometryColumn are ignored if not supported by the backend).
 
virtual QMultiMap< Qgis::SqlKeywordCategory, QStringList > sqlDictionary ()
 Returns a dictionary of SQL keywords supported by the provider.
 
virtual Qgis::SqlLayerDefinitionCapabilities sqlLayerDefinitionCapabilities ()
 Returns SQL layer definition capabilities (Filters, GeometryColumn, PrimaryKeys).
 
virtual SqlVectorLayerOptions sqlOptions (const QString &layerSource)
 Returns the SQL layer options from a layerSource.
 
virtual QList< Qgis::FieldDomainTypesupportedFieldDomainTypes () const
 Returns a list of field domain types which are supported by the provider.
 
virtual Qgis::RelationshipCapabilities supportedRelationshipCapabilities () const
 Returns the relationship capabilities supported by the provider.
 
virtual QList< Qgis::RelationshipCardinalitysupportedRelationshipCardinalities () const
 Returns a list of relationship cardinalities which are supported by the provider.
 
virtual QList< Qgis::RelationshipStrengthsupportedRelationshipStrengths () const
 Returns a list of relationship strengths which are supported by the provider.
 
virtual QgsAbstractDatabaseProviderConnection::TableProperty table (const QString &schema, const QString &table, QgsFeedback *feedback=nullptr) const
 Returns information on a table in the given schema.
 
virtual bool tableExists (const QString &schema, const QString &name) const
 Checks whether a table name exists in the given schema.
 
virtual QList< QgsAbstractDatabaseProviderConnection::TablePropertytables (const QString &schema=QString(), const QgsAbstractDatabaseProviderConnection::TableFlags &flags=QgsAbstractDatabaseProviderConnection::TableFlags(), QgsFeedback *feedback=nullptr) const
 Returns information on the tables in the given schema.
 
QList< QgsAbstractDatabaseProviderConnection::TablePropertytablesInt (const QString &schema=QString(), const int flags=0) const
 Returns information on the tables in the given schema.
 
virtual QString tableUri (const QString &schema, const QString &name) const
 Returns the URI string for the given table and schema.
 
virtual void updateRelationship (const QgsWeakRelation &relationship) const
 Updates an existing relationship in the database.
 
virtual void vacuum (const QString &schema, const QString &name) const
 Vacuum the database table with given schema and name (schema is ignored if not supported by the backend).
 
- Public Member Functions inherited from QgsAbstractProviderConnection
 QgsAbstractProviderConnection (const QString &name)
 Creates a new connection with name by reading its configuration from the settings.
 
 QgsAbstractProviderConnection (const QString &uri, const QVariantMap &configuration)
 Creates a new connection from the given uri and configuration.
 
virtual ~QgsAbstractProviderConnection ()=default
 
QVariantMap configuration () const
 Returns the connection configuration parameters.
 
virtual QIcon icon () const
 Returns an icon representing the connection.
 
virtual void remove (const QString &name) const =0
 Deletes the connection from the settings.
 
void setConfiguration (const QVariantMap &configuration)
 Sets the connection configuration.
 
void setUri (const QString &uri)
 Sets the connection data source URI to uri.
 
virtual void store (const QString &name) const =0
 Stores the connection in the settings.
 
QString uri () const
 Returns the connection data source URI string representation.
 

Protected Attributes

Capabilities mCapabilities = Capabilities()
 
Qgis::DatabaseProviderConnectionCapabilities2 mCapabilities2 = Qgis::DatabaseProviderConnectionCapabilities2()
 
GeometryColumnCapabilities mGeometryColumnCapabilities = GeometryColumnCapabilities()
 
QSet< QString > mIllegalFieldNames
 
QString mProviderKey
 
Qgis::SqlLayerDefinitionCapabilities mSqlLayerDefinitionCapabilities = Qgis::SqlLayerDefinitionCapabilities()
 

Detailed Description

The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connections.

This class performs low level DB operations without asking the user for confirmation or handling currently opened layers and the registry entries, it is responsibility of the client code to keep layers in sync. The class methods will throw exceptions in case the requested operation is not supported or cannot be performed without errors.

Since
QGIS 3.10

Definition at line 47 of file qgsabstractdatabaseproviderconnection.h.

Member Typedef Documentation

◆ Capabilities

Definition at line 519 of file qgsabstractdatabaseproviderconnection.h.

◆ GeometryColumnCapabilities

Definition at line 541 of file qgsabstractdatabaseproviderconnection.h.

◆ TableFlags

Definition at line 72 of file qgsabstractdatabaseproviderconnection.h.

Member Enumeration Documentation

◆ Capability

The Capability enum represents the operations supported by the connection.

See also
Qgis::DatabaseProviderConnectionCapability2
Enumerator
CreateVectorTable 

Can CREATE a vector (or aspatial) table/layer.

DropRasterTable 

Can DROP a raster table/layer.

DropVectorTable 

Can DROP a vector (or aspatial) table/layer.

RenameVectorTable 

Can RENAME a vector (or aspatial) table/layer.

RenameRasterTable 

Can RENAME a raster table/layer.

CreateSchema 

Can CREATE a schema.

DropSchema 

Can DROP a schema.

RenameSchema 

Can RENAME a schema.

ExecuteSql 

Can execute raw SQL queries (without returning results)

Vacuum 

Can run vacuum.

Tables 

Can list tables.

Schemas 

Can list schemas (if not set, the connection does not support schemas)

SqlLayers 

Can create vector layers from SQL SELECT queries.

TableExists 

Can check if table exists.

Spatial 

The connection supports spatial tables.

CreateSpatialIndex 

The connection can create spatial indices.

SpatialIndexExists 

The connection can determine if a spatial index exists.

DeleteSpatialIndex 

The connection can delete spatial indices for tables.

DeleteField 

Can delete an existing field/column.

DeleteFieldCascade 

Can delete an existing field/column with cascade.

AddField 

Can add a new field/column.

ListFieldDomains 

Can return a list of field domain names via fieldDomainNames()

Since
QGIS 3.26
RetrieveFieldDomain 

Can retrieve field domain details from provider via fieldDomain()

Since
QGIS 3.26
SetFieldDomain 

Can set the domain for an existing field via setFieldDomainName()

Since
QGIS 3.26
AddFieldDomain 

Can add new field domains to the database via addFieldDomain()

Since
QGIS 3.26
RenameField 

Can rename existing fields via renameField()

Since
QGIS 3.28
RetrieveRelationships 

Can retrieve relationships from the database.

Since
QGIS 3.28
AddRelationship 

Can add new relationships to the database via addRelationship()

Since
QGIS 3.30
UpdateRelationship 

Can update existing relationships in the database via updateRelationship()

Since
QGIS 3.30
DeleteRelationship 

Can delete existing relationships from the database via deleteRelationship()

Since
QGIS 3.30

Definition at line 485 of file qgsabstractdatabaseproviderconnection.h.

◆ GeometryColumnCapability

The GeometryColumnCapability enum represents the geometry column features supported by the connection.

Since
QGIS 3.16
Enumerator

Supports Z dimension.

Supports M dimension.

SinglePart 

Multi and single part types are distinct types. Deprecated since QGIS 3.28 – use the granular SinglePoint/SingleLineString/SinglePolygon capabilities instead.

Curves 

Supports curves.

SinglePoint 

Supports single point types (as distinct from multi point types)

Since
QGIS 3.28
SingleLineString 

Supports single linestring types (as distinct from multi line types)

Since
QGIS 3.28
SinglePolygon 

Supports single polygon types (as distinct from multi polygon types)

Since
QGIS 3.28
PolyhedralSurfaces 

Supports polyhedral surfaces (PolyhedralSurface, TIN) types (as distinct from multi polygon types)

Since
QGIS 3.40

Definition at line 527 of file qgsabstractdatabaseproviderconnection.h.

◆ TableFlag

Flags for table properties.

Flags can be useful for filtering the tables returned from tables().

Enumerator
Aspatial 

Aspatial table (it does not contain any geometry column)

Vector 

Vector table (it does contain one geometry column)

Raster 

Raster table.

View 

View table.

MaterializedView 

Materialized view table.

Foreign 

Foreign data wrapper.

IncludeSystemTables 

Include system tables.

Since
QGIS 3.30

Definition at line 60 of file qgsabstractdatabaseproviderconnection.h.

Constructor & Destructor Documentation

◆ QgsAbstractDatabaseProviderConnection() [1/2]

QgsAbstractDatabaseProviderConnection::QgsAbstractDatabaseProviderConnection ( const QString &  name)

Creates a new connection with name by reading its configuration from the settings.

If a connection with this name cannot be found, an empty connection will be returned.

Definition at line 27 of file qgsabstractdatabaseproviderconnection.cpp.

◆ QgsAbstractDatabaseProviderConnection() [2/2]

QgsAbstractDatabaseProviderConnection::QgsAbstractDatabaseProviderConnection ( const QString &  uri,
const QVariantMap &  configuration 
)

Creates a new connection from the given uri and configuration.

The connection is not automatically stored in the settings.

See also
store()

Definition at line 33 of file qgsabstractdatabaseproviderconnection.cpp.

Member Function Documentation

◆ addField()

void QgsAbstractDatabaseProviderConnection::addField ( const QgsField field,
const QString &  schema,
const QString &  tableName 
) const
virtual

Adds a field.

Parameters
fieldspecification of the new field
schemaname of the schema (schema is ignored if not supported by the backend).
tableNamename of the table
Note
it is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.16

Definition at line 1217 of file qgsabstractdatabaseproviderconnection.cpp.

◆ addFieldDomain()

void QgsAbstractDatabaseProviderConnection::addFieldDomain ( const QgsFieldDomain domain,
const QString &  schema 
) const
virtual

Adds a new field domain to the database.

Parameters
domainfield domain to add
schemaname of the schema (schema is ignored if not supported by the backend).
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.26

Definition at line 1371 of file qgsabstractdatabaseproviderconnection.cpp.

◆ addRelationship()

void QgsAbstractDatabaseProviderConnection::addRelationship ( const QgsWeakRelation relationship) const
virtual

Adds a new field relationship to the database.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.30

Definition at line 1392 of file qgsabstractdatabaseproviderconnection.cpp.

◆ capabilities()

QgsAbstractDatabaseProviderConnection::Capabilities QgsAbstractDatabaseProviderConnection::capabilities ( ) const

Returns connection capabilities.

See also
capabilities2()

Definition at line 39 of file qgsabstractdatabaseproviderconnection.cpp.

◆ capabilities2()

Qgis::DatabaseProviderConnectionCapabilities2 QgsAbstractDatabaseProviderConnection::capabilities2 ( ) const

Returns extended connection capabilities.

See also
capabilities()
Since
QGIS 3.32

Definition at line 44 of file qgsabstractdatabaseproviderconnection.cpp.

◆ createSchema()

void QgsAbstractDatabaseProviderConnection::createSchema ( const QString &  name) const
virtual

Creates a new schema with the specified name.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1137 of file qgsabstractdatabaseproviderconnection.cpp.

◆ createSpatialIndex()

void QgsAbstractDatabaseProviderConnection::createSpatialIndex ( const QString &  schema,
const QString &  name,
const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions options = QgsAbstractDatabaseProviderConnection::SpatialIndexOptions() 
) const
virtual

Creates a spatial index for the database table with given schema and name (schema is ignored if not supported by the backend).

The options argument can be used to provide extra options controlling the spatial index creation.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.14

Definition at line 1170 of file qgsabstractdatabaseproviderconnection.cpp.

◆ createSqlVectorLayer()

QgsVectorLayer * QgsAbstractDatabaseProviderConnection::createSqlVectorLayer ( const SqlVectorLayerOptions options) const
virtual

Creates and returns a (possibly invalid) vector layer based on the sql statement and optional options.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered or if SQL layer creation is not supported.
Since
QGIS 3.22

Definition at line 1175 of file qgsabstractdatabaseproviderconnection.cpp.

◆ createVectorTable()

void QgsAbstractDatabaseProviderConnection::createVectorTable ( const QString &  schema,
const QString &  name,
const QgsFields fields,
Qgis::WkbType  wkbType,
const QgsCoordinateReferenceSystem srs,
bool  overwrite,
const QMap< QString, QVariant > *  options 
) const
virtual

Creates an empty table with name in the given schema (schema is ignored if not supported by the backend).

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1067 of file qgsabstractdatabaseproviderconnection.cpp.

◆ deleteField()

void QgsAbstractDatabaseProviderConnection::deleteField ( const QString &  fieldName,
const QString &  schema,
const QString &  tableName,
bool  force = false 
) const
virtual

Deletes the field with the specified name.

Parameters
fieldNamename of the field to be deleted
schemaname of the schema (schema is ignored if not supported by the backend).
tableNamename of the table
forceif true, a DROP CASCADE will drop all related objects
Note
it is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.16

Definition at line 1192 of file qgsabstractdatabaseproviderconnection.cpp.

◆ deleteRelationship()

void QgsAbstractDatabaseProviderConnection::deleteRelationship ( const QgsWeakRelation relationship) const
virtual

Deletes an existing relationship in the database.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.30

Definition at line 1402 of file qgsabstractdatabaseproviderconnection.cpp.

◆ deleteSpatialIndex()

void QgsAbstractDatabaseProviderConnection::deleteSpatialIndex ( const QString &  schema,
const QString &  name,
const QString &  geometryColumn 
) const
virtual

Deletes the existing spatial index for the database table with given schema, name and geometryColumn (schema and geometryColumn are ignored if not supported by the backend).

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.14

Definition at line 1181 of file qgsabstractdatabaseproviderconnection.cpp.

◆ dropRasterTable()

void QgsAbstractDatabaseProviderConnection::dropRasterTable ( const QString &  schema,
const QString &  name 
) const
virtual

Drops a raster table with given schema (schema is ignored if not supported by the backend) and name.

Note
It is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1132 of file qgsabstractdatabaseproviderconnection.cpp.

◆ dropSchema()

void QgsAbstractDatabaseProviderConnection::dropSchema ( const QString &  name,
bool  force = false 
) const
virtual

Drops an entire schema with the specified name.

Parameters
namename of the schema to be dropped
forceif true, a DROP CASCADE will drop all related objects
Note
It is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1142 of file qgsabstractdatabaseproviderconnection.cpp.

◆ dropVectorTable()

void QgsAbstractDatabaseProviderConnection::dropVectorTable ( const QString &  schema,
const QString &  name 
) const
virtual

Drops a vector (or aspatial) table with given schema (schema is ignored if not supported by the backend) and name.

Note
It is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1103 of file qgsabstractdatabaseproviderconnection.cpp.

◆ execSql()

QgsAbstractDatabaseProviderConnection::QueryResult QgsAbstractDatabaseProviderConnection::execSql ( const QString &  sql,
QgsFeedback feedback = nullptr 
) const
virtual

Executes raw sql and returns the (possibly empty) query results, optionally feedback can be provided.

See also
executeSql()
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.18

Definition at line 1158 of file qgsabstractdatabaseproviderconnection.cpp.

◆ executeSql()

QList< QList< QVariant > > QgsAbstractDatabaseProviderConnection::executeSql ( const QString &  sql,
QgsFeedback feedback = nullptr 
) const
virtual

Executes raw sql and returns the (possibly empty) list of results in a multi-dimensional array, optionally feedback can be provided.

See also
execSql()
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1152 of file qgsabstractdatabaseproviderconnection.cpp.

◆ fieldDomain()

QgsFieldDomain * QgsAbstractDatabaseProviderConnection::fieldDomain ( const QString &  name) const
virtual

Returns the field domain with the specified name from the provider.

The caller takes ownership of the return object. Will return nullptr if no matching field domain is found.

This is supported on providers with the Capability::RetrieveFieldDomain capability only.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
See also
fieldDomainNames()
Since
QGIS 3.26

Definition at line 1360 of file qgsabstractdatabaseproviderconnection.cpp.

◆ fieldDomainNames()

QStringList QgsAbstractDatabaseProviderConnection::fieldDomainNames ( ) const
virtual

Returns a list of field domain names present on the provider.

This is supported on providers with the Capability::ListFieldDomains capability only.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
See also
fieldDomain()
Since
QGIS 3.26

Definition at line 1354 of file qgsabstractdatabaseproviderconnection.cpp.

◆ fields()

QgsFields QgsAbstractDatabaseProviderConnection::fields ( const QString &  schema,
const QString &  table,
QgsFeedback feedback = nullptr 
) const
virtual

Returns the fields of a table and schema.

Since QGIS 3.32 the optional feedback argument can be used to cancel the request.

Note
the default implementation creates a temporary vector layer, providers may choose to override this method for a greater efficiency of to overcome provider's behavior when the layer does not expose all fields (GPKG for example hides geometry and primary key column).
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.16

Definition at line 1338 of file qgsabstractdatabaseproviderconnection.cpp.

◆ geometryColumnCapabilities()

QgsAbstractDatabaseProviderConnection::GeometryColumnCapabilities QgsAbstractDatabaseProviderConnection::geometryColumnCapabilities ( )
virtual

Returns connection geometry column capabilities (Z, M, SinglePart, Curves).

Since
QGIS 3.16

Definition at line 49 of file qgsabstractdatabaseproviderconnection.cpp.

◆ illegalFieldNames()

QSet< QString > QgsAbstractDatabaseProviderConnection::illegalFieldNames ( ) const
virtual

Returns a list of field names which are considered illegal by the connection and should not be used when creating or altering fields.

Since
QGIS 3.30

Definition at line 1032 of file qgsabstractdatabaseproviderconnection.cpp.

◆ nativeTypes()

virtual QList< QgsVectorDataProvider::NativeType > QgsAbstractDatabaseProviderConnection::nativeTypes ( ) const
pure virtual

Returns a list of native types supported by the connection.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.16

◆ providerKey()

QString QgsAbstractDatabaseProviderConnection::providerKey ( ) const

Returns the provider key.

Since
QGIS 3.16

Definition at line 89 of file qgsabstractdatabaseproviderconnection.cpp.

◆ queryBuilder()

QgsProviderSqlQueryBuilder * QgsAbstractDatabaseProviderConnection::queryBuilder ( ) const
virtual

Returns a SQL query builder for the connection, which provides an interface for provider-specific creation of SQL queries.

The caller takes ownership of the returned object.

Since
QGIS 3.28

Definition at line 1062 of file qgsabstractdatabaseproviderconnection.cpp.

◆ relatedTableTypes()

QStringList QgsAbstractDatabaseProviderConnection::relatedTableTypes ( ) const
virtual

Returns a list of the related table types supported by the database format.

The related table type is a free-form string representing the type of related features, where the exact interpretation is format dependent. For instance, table types from GeoPackage relationships will directly reflect the categories from the GeoPackage related tables extension (i.e. "media", "simple attributes", "features", "attributes" and "tiles").

Since
QGIS 3.30

Definition at line 1057 of file qgsabstractdatabaseproviderconnection.cpp.

◆ relationships()

QList< QgsWeakRelation > QgsAbstractDatabaseProviderConnection::relationships ( const QString &  schema = QString(),
const QString &  tableName = QString() 
) const
virtual

Returns a list of relationships detected in the database.

This is supported on providers with the Capability::RetrieveRelationships capability only.

If a schema and/or tableName are specified, then only relationships where the specified table forms the left (or "parent" / "referenced") side of the relationship are retrieved.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.28

Definition at line 1386 of file qgsabstractdatabaseproviderconnection.cpp.

◆ renameField()

void QgsAbstractDatabaseProviderConnection::renameField ( const QString &  schema,
const QString &  tableName,
const QString &  name,
const QString &  newName 
) const
virtual

Renames an existing field.

Parameters
schemaname of the schema (schema is ignored if not supported by the backend).
tableNamename of the table
namecurrent name of field
newNamenew name for field
Note
it is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.28

Definition at line 1242 of file qgsabstractdatabaseproviderconnection.cpp.

◆ renameRasterTable()

void QgsAbstractDatabaseProviderConnection::renameRasterTable ( const QString &  schema,
const QString &  name,
const QString &  newName 
) const
virtual

Renames a raster table with given schema (schema is ignored if not supported by the backend) and name.

Note
It is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1098 of file qgsabstractdatabaseproviderconnection.cpp.

◆ renameSchema()

void QgsAbstractDatabaseProviderConnection::renameSchema ( const QString &  name,
const QString &  newName 
) const
virtual

Renames a schema with the specified name.

Raises a QgsProviderConnectionException if any errors are encountered.

Note
it is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1147 of file qgsabstractdatabaseproviderconnection.cpp.

◆ renameVectorTable()

void QgsAbstractDatabaseProviderConnection::renameVectorTable ( const QString &  schema,
const QString &  name,
const QString &  newName 
) const
virtual

Renames a vector or aspatial table with given schema (schema is ignored if not supported by the backend) and name.

Note
It is responsibility of the caller to handle open layers and registry entries.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1086 of file qgsabstractdatabaseproviderconnection.cpp.

◆ schemas()

QStringList QgsAbstractDatabaseProviderConnection::schemas ( ) const
virtual

Returns information about the existing schemas.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1302 of file qgsabstractdatabaseproviderconnection.cpp.

◆ searchLayerMetadata()

QList< QgsLayerMetadataProviderResult > QgsAbstractDatabaseProviderConnection::searchLayerMetadata ( const QgsMetadataSearchContext searchContext,
const QString &  searchString = QString(),
const QgsRectangle geographicExtent = QgsRectangle(),
QgsFeedback feedback = nullptr 
) const
virtual

Search the stored layer metadata in the connection, optionally limiting the search to the metadata identifier, title, abstract, keywords and categories.

searchContext context for the search searchString limit the search to metadata having an extent intersecting geographicExtent, an optional feedback can be used to monitor and control the search process.

The default implementation raises a QgsNotSupportedException, data providers may implement the search functionality.

A QgsProviderConnectionException is raised in case of errors happening during the search for providers that implement the search functionality.

Returns
a (possibly empty) list of QgsLayerMetadataProviderResult, throws a QgsProviderConnectionException if any error occurred during the search.
Exceptions
QgsProviderConnectionException
QgsNotSupportedException
Since
QGIS 3.28

Definition at line 1123 of file qgsabstractdatabaseproviderconnection.cpp.

◆ setFieldAlias()

void QgsAbstractDatabaseProviderConnection::setFieldAlias ( const QString &  fieldName,
const QString &  schema,
const QString &  tableName,
const QString &  alias 
) const
virtual

Sets the alias for the existing field with the specified name.

Parameters
fieldNamename of the field to be modified
schemaname of the schema (schema is ignored if not supported by the backend).
tableNamename of the table
aliasalias to set for the field. Set to an empty string to remove a previously set alias.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.32

Definition at line 1376 of file qgsabstractdatabaseproviderconnection.cpp.

◆ setFieldComment()

void QgsAbstractDatabaseProviderConnection::setFieldComment ( const QString &  fieldName,
const QString &  schema,
const QString &  tableName,
const QString &  comment 
) const
virtual

Sets the comment for the existing field with the specified name.

Parameters
fieldNamename of the field to be modified
schemaname of the schema (schema is ignored if not supported by the backend).
tableNamename of the table
commentcomment to set for the field. Set to an empty string to remove a previously set comment.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.32

Definition at line 1381 of file qgsabstractdatabaseproviderconnection.cpp.

◆ setFieldDomainName()

void QgsAbstractDatabaseProviderConnection::setFieldDomainName ( const QString &  fieldName,
const QString &  schema,
const QString &  tableName,
const QString &  domainName 
) const
virtual

Sets the field domain name for the existing field with the specified name.

Parameters
fieldNamename of the field to be modified
schemaname of the schema (schema is ignored if not supported by the backend).
tableNamename of the table
domainNamename of the domain to set for the field. Must be an existing field domain (see fieldDomainNames()). Set to an empty string to remove a previously set domain.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.26

Definition at line 1366 of file qgsabstractdatabaseproviderconnection.cpp.

◆ spatialIndexExists()

bool QgsAbstractDatabaseProviderConnection::spatialIndexExists ( const QString &  schema,
const QString &  name,
const QString &  geometryColumn 
) const
virtual

Determines whether a spatial index exists for the database table with given schema, name and geometryColumn (schema and geometryColumn are ignored if not supported by the backend).

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.14

Definition at line 1186 of file qgsabstractdatabaseproviderconnection.cpp.

◆ sqlDictionary()

QMultiMap< Qgis::SqlKeywordCategory, QStringList > QgsAbstractDatabaseProviderConnection::sqlDictionary ( )
virtual

Returns a dictionary of SQL keywords supported by the provider.

The default implementation returns an list of common reserved words under the "Keyword" and "Constant" categories.

Subclasses should add provider- and/or connection- specific words.

Since
QGIS 3.22

Definition at line 94 of file qgsabstractdatabaseproviderconnection.cpp.

◆ sqlLayerDefinitionCapabilities()

Qgis::SqlLayerDefinitionCapabilities QgsAbstractDatabaseProviderConnection::sqlLayerDefinitionCapabilities ( )
virtual

Returns SQL layer definition capabilities (Filters, GeometryColumn, PrimaryKeys).

Since
QGIS 3.22

Definition at line 54 of file qgsabstractdatabaseproviderconnection.cpp.

◆ sqlOptions()

QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions QgsAbstractDatabaseProviderConnection::sqlOptions ( const QString &  layerSource)
virtual

Returns the SQL layer options from a layerSource.

Note
the default implementation returns a default constructed option object.
Exceptions
QgsProviderConnectionExceptionif any errors are encountered or if SQL layer creation is not supported.
Since
QGIS 3.22

Definition at line 1092 of file qgsabstractdatabaseproviderconnection.cpp.

◆ supportedFieldDomainTypes()

QList< Qgis::FieldDomainType > QgsAbstractDatabaseProviderConnection::supportedFieldDomainTypes ( ) const
virtual

Returns a list of field domain types which are supported by the provider.

Since
QGIS 3.28

Definition at line 1037 of file qgsabstractdatabaseproviderconnection.cpp.

◆ supportedRelationshipCapabilities()

Qgis::RelationshipCapabilities QgsAbstractDatabaseProviderConnection::supportedRelationshipCapabilities ( ) const
virtual

Returns the relationship capabilities supported by the provider.

Since
QGIS 3.30

Definition at line 1052 of file qgsabstractdatabaseproviderconnection.cpp.

◆ supportedRelationshipCardinalities()

QList< Qgis::RelationshipCardinality > QgsAbstractDatabaseProviderConnection::supportedRelationshipCardinalities ( ) const
virtual

Returns a list of relationship cardinalities which are supported by the provider.

Since
QGIS 3.30

Definition at line 1042 of file qgsabstractdatabaseproviderconnection.cpp.

◆ supportedRelationshipStrengths()

QList< Qgis::RelationshipStrength > QgsAbstractDatabaseProviderConnection::supportedRelationshipStrengths ( ) const
virtual

Returns a list of relationship strengths which are supported by the provider.

Since
QGIS 3.30

Definition at line 1047 of file qgsabstractdatabaseproviderconnection.cpp.

◆ table()

QgsAbstractDatabaseProviderConnection::TableProperty QgsAbstractDatabaseProviderConnection::table ( const QString &  schema,
const QString &  table,
QgsFeedback feedback = nullptr 
) const
virtual

Returns information on a table in the given schema.

Since QGIS 3.32 the optional feedback argument can be used to cancel the request.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered or if the table does not exist.
Note
Not available in Python bindings
Since
QGIS 3.12

Definition at line 1281 of file qgsabstractdatabaseproviderconnection.cpp.

◆ tableExists()

bool QgsAbstractDatabaseProviderConnection::tableExists ( const QString &  schema,
const QString &  name 
) const
virtual

Checks whether a table name exists in the given schema.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1108 of file qgsabstractdatabaseproviderconnection.cpp.

◆ tables()

QList< QgsAbstractDatabaseProviderConnection::TableProperty > QgsAbstractDatabaseProviderConnection::tables ( const QString &  schema = QString(),
const QgsAbstractDatabaseProviderConnection::TableFlags flags = QgsAbstractDatabaseProviderConnection::TableFlags(),
QgsFeedback feedback = nullptr 
) const
virtual

Returns information on the tables in the given schema.

Parameters
schemaname of the schema (ignored if not supported by the backend)
flagsfilter tables by flags, this option completely overrides search options stored in the connection
feedbackcan be used to cancel the request (since QGIS 3.32)
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Note
Not available in Python bindings

Definition at line 1274 of file qgsabstractdatabaseproviderconnection.cpp.

◆ tablesInt()

QList< QgsAbstractDatabaseProviderConnection::TableProperty > QgsAbstractDatabaseProviderConnection::tablesInt ( const QString &  schema = QString(),
const int  flags = 0 
) const

Returns information on the tables in the given schema.

Parameters
schemaname of the schema (ignored if not supported by the backend)
flagsfilter tables by flags, this option completely overrides search options stored in the connection
Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1296 of file qgsabstractdatabaseproviderconnection.cpp.

◆ tableUri()

QString QgsAbstractDatabaseProviderConnection::tableUri ( const QString &  schema,
const QString &  name 
) const
virtual

Returns the URI string for the given table and schema.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.12

Definition at line 60 of file qgsabstractdatabaseproviderconnection.cpp.

◆ updateRelationship()

void QgsAbstractDatabaseProviderConnection::updateRelationship ( const QgsWeakRelation relationship) const
virtual

Updates an existing relationship in the database.

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.
Since
QGIS 3.30

Definition at line 1397 of file qgsabstractdatabaseproviderconnection.cpp.

◆ vacuum()

void QgsAbstractDatabaseProviderConnection::vacuum ( const QString &  schema,
const QString &  name 
) const
virtual

Vacuum the database table with given schema and name (schema is ignored if not supported by the backend).

Exceptions
QgsProviderConnectionExceptionif any errors are encountered.

Definition at line 1165 of file qgsabstractdatabaseproviderconnection.cpp.

Member Data Documentation

◆ mCapabilities

Capabilities QgsAbstractDatabaseProviderConnection::mCapabilities = Capabilities()
protected

Definition at line 1148 of file qgsabstractdatabaseproviderconnection.h.

◆ mCapabilities2

Qgis::DatabaseProviderConnectionCapabilities2 QgsAbstractDatabaseProviderConnection::mCapabilities2 = Qgis::DatabaseProviderConnectionCapabilities2()
protected

Definition at line 1149 of file qgsabstractdatabaseproviderconnection.h.

◆ mGeometryColumnCapabilities

GeometryColumnCapabilities QgsAbstractDatabaseProviderConnection::mGeometryColumnCapabilities = GeometryColumnCapabilities()
protected

Definition at line 1151 of file qgsabstractdatabaseproviderconnection.h.

◆ mIllegalFieldNames

QSet<QString> QgsAbstractDatabaseProviderConnection::mIllegalFieldNames
protected

Definition at line 1154 of file qgsabstractdatabaseproviderconnection.h.

◆ mProviderKey

QString QgsAbstractDatabaseProviderConnection::mProviderKey
protected

Definition at line 1153 of file qgsabstractdatabaseproviderconnection.h.

◆ mSqlLayerDefinitionCapabilities

Qgis::SqlLayerDefinitionCapabilities QgsAbstractDatabaseProviderConnection::mSqlLayerDefinitionCapabilities = Qgis::SqlLayerDefinitionCapabilities()
protected

Definition at line 1152 of file qgsabstractdatabaseproviderconnection.h.


The documentation for this class was generated from the following files: