QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
49 static QMetaEnum metaEnum = QMetaEnum::fromType<QgsAbstractDatabaseProviderConnection::Capability>();
50 const QString capName { metaEnum.valueToKey( capability ) };
62 const QMap<QString, QVariant> *
69 Q_UNUSED( overwrite );
77 checkCapability( Capability::RenameVectorTable );
82 checkCapability( Capability::RenameRasterTable );
87 checkCapability( Capability::DropVectorTable );
92 checkCapability( Capability::TableExists );
93 const QList<QgsAbstractDatabaseProviderConnection::TableProperty> constTables {
tables( schema ) };
94 for (
const auto &t : constTables )
96 if ( t.tableName() == name )
106 checkCapability( Capability::DropRasterTable );
111 checkCapability( Capability::CreateSchema );
116 checkCapability( Capability::DropSchema );
121 checkCapability( Capability::RenameSchema );
126 checkCapability( Capability::ExecuteSql );
127 return QList<QList<QVariant>>();
132 checkCapability( Capability::Vacuum );
137 checkCapability( Capability::CreateSpatialIndex );
142 checkCapability( Capability::DeleteSpatialIndex );
147 checkCapability( Capability::SpatialIndexExists );
153 checkCapability( Capability::Tables );
154 return QList<QgsAbstractDatabaseProviderConnection::TableProperty>();
160 checkCapability( Capability::Tables );
161 const QList<QgsAbstractDatabaseProviderConnection::TableProperty> constTables {
tables( schema ) };
162 for (
const auto &t : constTables )
164 if ( t.tableName() == name )
176 return tables( schema,
static_cast<QgsAbstractDatabaseProviderConnection::TableFlags
>( flags ) );
182 checkCapability( Capability::Schemas );
183 return QStringList();
200 for (
const auto &t : qgis::as_const( mGeometryColumnTypes ) )
207 mGeometryColumnTypes.push_back( toAdd );
212 return mGeometryColumnTypes;
218 QString n = mTableName;
219 if ( mGeometryColumnCount > 1 ) n +=
'.' + mGeometryColumn;
227 Q_ASSERT( index >= 0 && index < mGeometryColumnTypes.size() );
229 property.mGeometryColumnTypes << mGeometryColumnTypes[ index ];
230 property.mSchema = mSchema;
231 property.mTableName = mTableName;
232 property.mGeometryColumn = mGeometryColumn;
233 property.mPkColumns = mPkColumns;
234 property.mGeometryColumnCount = mGeometryColumnCount;
235 property.mFlags = mFlags;
236 property.mComment = mComment;
237 property.mInfo = mInfo;
243 mFlags.setFlag( flag );
258 return mSchema == other.mSchema &&
259 mTableName == other.mTableName &&
260 mGeometryColumn == other.mGeometryColumn &&
261 mGeometryColumnCount == other.mGeometryColumnCount &&
262 mPkColumns == other.mPkColumns &&
263 mFlags == other.mFlags &&
264 mComment == other.mComment &&
265 mInfo == other.mInfo;
271 mGeometryColumnTypes = columnTypes;
277 return mGeometryColumnCount;
282 mGeometryColumnCount = geometryColumnCount;
317 QList<QgsCoordinateReferenceSystem> crss;
318 for (
const auto &t : qgis::as_const( mGeometryColumnTypes ) )
320 crss.push_back( t.crs );
332 mPkColumns = pkColumns;
337 return mGeometryColumn;
342 mGeometryColumn = geometryColumn;
void setGeometryColumnTypes(const QList< QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType > &geometryColumnTypes)
Sets the geometry column types to geometryColumnTypes.
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 s...
void setSchema(const QString &schema)
Sets the schema.
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.
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...
virtual void dropSchema(const QString &name, bool force=false) const SIP_THROW(QgsProviderConnectionException)
Drops an entire schema with the specified name.
static int coordDimensions(Type type)
Returns the coordinate dimension of the geometry type as an integer.
virtual void createSchema(const QString &name) const SIP_THROW(QgsProviderConnectionException)
Creates a new schema with the specified name.
const QgsCoordinateReferenceSystem & crs
void setPrimaryKeyColumns(const QStringList &primaryKeyColumns)
Sets the primary key column names to primaryKeyColumns.
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,...
virtual QList< QgsAbstractDatabaseProviderConnection::TableProperty > tables(const QString &schema=QString(), const QgsAbstractDatabaseProviderConnection::TableFlags &flags=nullptr) const
Returns information on the tables in the given schema.
QString geometryColumn() const
Returns the geometry column name.
Type
The WKB type describes the number of dimensions a geometry has.
QStringList primaryKeyColumns() const
Returns the list of primary key column names.
void addGeometryColumnType(const QgsWkbTypes::Type &type, const QgsCoordinateReferenceSystem &crs)
Appends the geometry column type with the given srid to the geometry column types list.
QString defaultName() const
Returns the default name for the table entry.
The TableProperty class represents a database table or view.
void setFlag(const TableFlag &flag)
Sets a flag.
virtual bool tableExists(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Checks whether a table name exists in the given schema.
QVariantMap info() const
Returns additional information about the table.
virtual void renameSchema(const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException)
Renames a schema with the specified name.
void setGeometryColumnCount(int geometryColumnCount)
Sets the geometryColumnCount.
QgsAbstractDatabaseProviderConnection(const QString &name)
Creates a new connection with name by reading its configuration from the settings.
Capabilities mCapabilities
int maxCoordinateDimensions() const
Returns the maximum coordinate dimensions of the geometries of a vector table.
QList< QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType > geometryColumnTypes() const
Returns the list of geometry column types and CRSs.
QList< QgsCoordinateReferenceSystem > crsList() const
Returns the list of CRSs supported by the geometry column.
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 backe...
virtual QgsAbstractDatabaseProviderConnection::TableProperty table(const QString &schema, const QString &table) const
Returns information on a table in the given schema.
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 backe...
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 ...
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.
Contains extra options relating to spatial index creation.
void setFlags(const TableFlags &flags)
Sets the table flags.
QString comment() const
Returns the table comment.
QString tableName() const
Returns the table name.
Capability
The Capability enum represent the operations supported by the connection.
TableProperty at(int index) const
Returns the table property corresponding to the geometry type at the given index.
void setTableName(const QString &name)
Sets the table name to name.
void setInfo(const QVariantMap &info)
Sets additional information about the table to info.
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 backe...
int geometryColumnCount() const
Returns the number of geometry columns in the original table this entry refers to.
TableFlag
Flags for table properties.
The GeometryColumnType struct represents the combination of geometry type and CRS for the table geome...
The QgsAbstractProviderConnection provides an interface for data provider connections.
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 backe...
TableFlags flags() const
Returns the table flags.
void setComment(const QString &comment)
Sets the table comment.
void setGeometryColumn(const QString &geometryColumn)
Sets the geometry column name to geometryColumn.
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.
QString schema() const
Returns the schema or an empty string for backends that do not support a schema.
virtual QStringList schemas() const SIP_THROW(QgsProviderConnectionException)
Returns information about the existing schemas.
bool operator==(const QgsAbstractDatabaseProviderConnection::TableProperty &other) const
virtual QString tableUri(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Returns the URI string for the given table and schema.
Capabilities capabilities() const
Returns connection capabilities.