QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connections. More...
#include <qgsabstractdatabaseproviderconnection.h>
Classes | |
struct | SpatialIndexOptions |
Contains extra options relating to spatial index creation. More... | |
struct | TableProperty |
The TableProperty class represents a database table or view. More... | |
Public Types | |
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 } |
The Capability enum represent the operations supported by the connection. More... | |
enum | TableFlag { Aspatial = 1 << 1, Vector = 1 << 2, Raster = 1 << 3, View = 1 << 4, MaterializedView = 1 << 5, Foreign = 1 << 6 } |
Flags for table properties. More... | |
Public Member Functions | |
QgsAbstractDatabaseProviderConnection (const QString &name) | |
Creates a new connection with name by reading its configuration from the settings. More... | |
QgsAbstractDatabaseProviderConnection (const QString &uri, const QVariantMap &configuration) | |
Creates a new connection from the given uri and configuration. More... | |
Capabilities | capabilities () const |
Returns connection capabilities. More... | |
virtual void | createSchema (const QString &name) const SIP_THROW(QgsProviderConnectionException) |
Creates a new schema with the specified name. More... | |
virtual void | createSpatialIndex (const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options=QgsAbstractDatabaseProviderConnection::SpatialIndexOptions()) const SIP_THROW(QgsProviderConnectionException) |
Creates a spatial index for the database table with given schema and name (schema is ignored if not supported by the backend). More... | |
virtual void | createVectorTable (const QString &schema, const QString &name, const QgsFields &fields, QgsWkbTypes::Type wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap< QString, QVariant > *options) const SIP_THROW(QgsProviderConnectionException) |
Creates an empty table with name in the given schema (schema is ignored if not supported by the backend). More... | |
virtual void | deleteSpatialIndex (const QString &schema, const QString &name, const QString &geometryColumn) const SIP_THROW(QgsProviderConnectionException) |
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). More... | |
virtual void | dropRasterTable (const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException) |
Drops a raster table with given schema (schema is ignored if not supported by the backend) and name. More... | |
virtual void | dropSchema (const QString &name, bool force=false) const SIP_THROW(QgsProviderConnectionException) |
Drops an entire schema with the specified name. More... | |
virtual void | dropVectorTable (const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException) |
Drops a vector (or aspatial) table with given schema (schema is ignored if not supported by the backend) and name. More... | |
virtual QList< QList< QVariant > > | executeSql (const QString &sql) const SIP_THROW(QgsProviderConnectionException) |
Executes raw sql and returns the (possibly empty) list of results in a multi-dimensional array. More... | |
virtual void | renameRasterTable (const QString &schema, const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException) |
Renames a raster table with given schema (schema is ignored if not supported by the backend) and name. More... | |
virtual void | renameSchema (const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException) |
Renames a schema with the specified name. More... | |
virtual void | renameVectorTable (const QString &schema, const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException) |
Renames a vector or aspatial table with given schema (schema is ignored if not supported by the backend) and name. More... | |
virtual QStringList | schemas () const SIP_THROW(QgsProviderConnectionException) |
Returns information about the existing schemas. More... | |
virtual bool | spatialIndexExists (const QString &schema, const QString &name, const QString &geometryColumn) const SIP_THROW(QgsProviderConnectionException) |
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). More... | |
virtual QgsAbstractDatabaseProviderConnection::TableProperty | table (const QString &schema, const QString &table) const |
Returns information on a table in the given schema. More... | |
virtual bool | tableExists (const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException) |
Checks whether a table name exists in the given schema. More... | |
virtual QList< QgsAbstractDatabaseProviderConnection::TableProperty > | tables (const QString &schema=QString(), const QgsAbstractDatabaseProviderConnection::TableFlags &flags=nullptr) const |
Returns information on the tables in the given schema. More... | |
QList< QgsAbstractDatabaseProviderConnection::TableProperty > | tablesInt (const QString &schema=QString(), const int flags=0) const SIP_THROW(QgsProviderConnectionException) |
Returns information on the tables in the given schema. More... | |
virtual QString | tableUri (const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException) |
Returns the URI string for the given table and schema. More... | |
virtual void | vacuum (const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException) |
Vacuum the database table with given schema and name (schema is ignored if not supported by the backend). More... | |
![]() | |
QgsAbstractProviderConnection (const QString &name) | |
Creates a new connection with name by reading its configuration from the settings. More... | |
QgsAbstractProviderConnection (const QString &uri, const QVariantMap &configuration) | |
Creates a new connection from the given uri and configuration. More... | |
virtual | ~QgsAbstractProviderConnection ()=default |
QVariantMap | configuration () const |
Returns the connection configuration parameters. More... | |
virtual QIcon | icon () const |
Returns an icon representing the connection. More... | |
virtual void | remove (const QString &name) const =0 |
Deletes the connection from the settings. More... | |
void | setConfiguration (const QVariantMap &configuration) |
Sets the connection configuration. More... | |
void | setUri (const QString &uri) |
Sets the connection data source URI to uri. More... | |
virtual void | store (const QString &name) const =0 |
Stores the connection in the settings. More... | |
QString | uri () const |
Returns the connection data source URI string representation. More... | |
Protected Attributes | |
Capabilities | mCapabilities = nullptr |
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.
Definition at line 40 of file qgsabstractdatabaseproviderconnection.h.
The Capability enum represent the operations supported by the connection.
Definition at line 290 of file qgsabstractdatabaseproviderconnection.h.
Flags for table properties.
Flags can be useful for filtering the tables returned from tables().
Definition at line 67 of file qgsabstractdatabaseproviderconnection.h.
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 21 of file qgsabstractdatabaseproviderconnection.cpp.
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.
Definition at line 27 of file qgsabstractdatabaseproviderconnection.cpp.
QgsAbstractDatabaseProviderConnection::Capabilities QgsAbstractDatabaseProviderConnection::capabilities | ( | ) | const |
Returns connection capabilities.
Definition at line 32 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Creates a new schema with the specified name.
QgsProviderConnectionException |
Definition at line 109 of file qgsabstractdatabaseproviderconnection.cpp.
|
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.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 135 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Creates an empty table with name in the given schema (schema is ignored if not supported by the backend).
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 56 of file qgsabstractdatabaseproviderconnection.cpp.
|
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).
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 140 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Drops a raster table with given schema (schema is ignored if not supported by the backend) and name.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 104 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Drops an entire schema with the specified name.
Raises a QgsProviderConnectionException if any errors are encountered.
name | name of the schema to be dropped |
force | if true , a DROP CASCADE will drop all related objects |
QgsProviderConnectionException |
Definition at line 114 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Drops a vector (or aspatial) table with given schema (schema is ignored if not supported by the backend) and name.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 85 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Executes raw sql and returns the (possibly empty) list of results in a multi-dimensional array.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 124 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Renames a raster table with given schema (schema is ignored if not supported by the backend) and name.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 80 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Renames a schema with the specified name.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 119 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Renames a vector or aspatial table with given schema (schema is ignored if not supported by the backend) and name.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 75 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Returns information about the existing schemas.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 180 of file qgsabstractdatabaseproviderconnection.cpp.
|
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).
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 145 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Returns information on a table in the given schema.
Raises a QgsProviderConnectionException if any errors are encountered or if the table does not exist.
QgsProviderConnectionException |
Definition at line 158 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Checks whether a table name exists in the given schema.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 90 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Returns information on the tables in the given schema.
Raises a QgsProviderConnectionException if any errors are encountered.
schema | name of the schema (ignored if not supported by the backend) |
flags | filter tables by flags, this option completely overrides search options stored in the connection |
QgsProviderConnectionException |
Definition at line 151 of file qgsabstractdatabaseproviderconnection.cpp.
QList< QgsAbstractDatabaseProviderConnection::TableProperty > QgsAbstractDatabaseProviderConnection::tablesInt | ( | const QString & | schema = QString() , |
const int | flags = 0 |
||
) | const |
Returns information on the tables in the given schema.
Raises a QgsProviderConnectionException if any errors are encountered.
schema | name of the schema (ignored if not supported by the backend) |
flags | filter tables by flags, this option completely overrides search options stored in the connection |
QgsProviderConnectionException |
Definition at line 174 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Returns the URI string for the given table and schema.
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 37 of file qgsabstractdatabaseproviderconnection.cpp.
|
virtual |
Vacuum the database table with given schema and name (schema is ignored if not supported by the backend).
Raises a QgsProviderConnectionException if any errors are encountered.
QgsProviderConnectionException |
Definition at line 130 of file qgsabstractdatabaseproviderconnection.cpp.
|
protected |
Definition at line 522 of file qgsabstractdatabaseproviderconnection.h.