42 static QMetaEnum metaEnum = QMetaEnum::fromType<QgsAbstractDatabaseProviderConnection::Capability>();
43 const QString capName { metaEnum.valueToKey( capability ) };
55 const QMap<QString, QVariant> *
62 Q_UNUSED( overwrite );
70 checkCapability( Capability::RenameVectorTable );
75 checkCapability( Capability::RenameRasterTable );
80 checkCapability( Capability::DropVectorTable );
85 checkCapability( Capability::TableExists );
86 const QList<QgsAbstractDatabaseProviderConnection::TableProperty> constTables {
tables( schema ) };
87 for (
const auto &t : constTables )
89 if ( t.tableName() == name )
99 checkCapability( Capability::DropRasterTable );
104 checkCapability( Capability::CreateSchema );
109 checkCapability( Capability::DropSchema );
114 checkCapability( Capability::RenameSchema );
119 checkCapability( Capability::ExecuteSql );
120 return QList<QList<QVariant>>();
125 checkCapability( Capability::Vacuum );
130 checkCapability( Capability::Tables );
131 return QList<QgsAbstractDatabaseProviderConnection::TableProperty>();
136 return tables( schema, static_cast<QgsAbstractDatabaseProviderConnection::TableFlags>( flags ) );
142 checkCapability( Capability::Schemas );
143 return QStringList();
160 for (
const auto &t : qgis::as_const( mGeometryColumnTypes ) )
167 mGeometryColumnTypes.push_back( toAdd );
172 return mGeometryColumnTypes;
178 QString n = mTableName;
179 if ( mGeometryColumnCount > 1 ) n +=
'.' + mGeometryColumn;
187 Q_ASSERT( index >= 0 && index < mGeometryColumnTypes.size() );
189 property.mGeometryColumnTypes << mGeometryColumnTypes[ index ];
190 property.mSchema = mSchema;
191 property.mTableName = mTableName;
192 property.mGeometryColumn = mGeometryColumn;
193 property.mPkColumns = mPkColumns;
194 property.mGeometryColumnCount = mGeometryColumnCount;
195 property.mFlags = mFlags;
196 property.mComment = mComment;
197 property.mInfo = mInfo;
203 mFlags.setFlag( flag );
219 mGeometryColumnTypes = columnTypes;
225 return mGeometryColumnCount;
230 mGeometryColumnCount = geometryColumnCount;
265 QList<QgsCoordinateReferenceSystem> crss;
266 for (
const auto &t : qgis::as_const( mGeometryColumnTypes ) )
268 crss.push_back( t.crs );
280 mPkColumns = pkColumns;
285 return mGeometryColumn;
290 mGeometryColumn = geometryColumn;
QString defaultName() const
Returns the default name for the table entry.
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...
void setPrimaryKeyColumns(const QStringList &primaryKeyColumns)
Sets the primary key column names to primaryKeyColumns.
void setFlag(const TableFlag &flag)
Sets a flag.
Capability
The Capability enum represent the operations supported by the connection.
virtual bool tableExists(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Checks whether a table name exists in the given schema.
virtual void dropSchema(const QString &name, bool force=false) const SIP_THROW(QgsProviderConnectionException)
Drops an entire schema with the specified name.
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...
void setInfo(const QVariantMap &info)
Sets additional information about the table to info.
QStringList primaryKeyColumns() const
Returns the list of primary key column names.
QList< QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType > geometryColumnTypes() const
Returns the list of geometry column types and CRSs.
void addGeometryColumnType(const QgsWkbTypes::Type &type, const QgsCoordinateReferenceSystem &crs)
Appends the geometry column type with the given srid to the geometry column types list...
virtual void createSchema(const QString &name) const SIP_THROW(QgsProviderConnectionException)
Creates a new schema with the specified name.
TableFlags flags() const
Returns the table flags.
Container of fields for a vector layer.
int geometryColumnCount() const
Returns the number of geometry columns in the original table this entry refers to.
void setGeometryColumnTypes(const QList< QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType > &geometryColumnTypes)
Sets the geometry column types to geometryColumnTypes.
void setGeometryColumnCount(int geometryColumnCount)
Sets the geometryColumnCount.
QString geometryColumn() const
Returns the geometry column name.
const QgsCoordinateReferenceSystem & crs
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...
virtual void renameSchema(const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException)
Renames a schema with the specified name.
The QgsAbstractProviderConnection provides an interface for data provider connections.
The GeometryColumnType struct represents the combination of geometry type and CRS for the table geome...
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...
Type
The WKB type describes the number of dimensions a geometry has.
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...
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 QStringList schemas() const SIP_THROW(QgsProviderConnectionException)
Returns information about the existing schemas.
The TableProperty class represents a database table or view.
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...
QString uri() const
Returns the connection data source URI string representation.
TableFlag
Flags for table properties.
QVariantMap configuration() const
Returns the connection configuration parameters.
void setTableName(const QString &name)
Sets the table name to name.
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.
TableProperty at(int index) const
Returns the table property corresponding to the geometry type at the given index. ...
QList< QgsCoordinateReferenceSystem > crsList() const
Returns the list of CRSs supported by the geometry column.
void setFlags(const TableFlags &flags)
Sets the table flags.
QString tableName() const
Returns the table name.
Capabilities capabilities() const
Returns connection capabilities.
void setComment(const QString &comment)
Sets the table comment.
virtual QList< QgsAbstractDatabaseProviderConnection::TableProperty > tables(const QString &schema=QString(), const QgsAbstractDatabaseProviderConnection::TableFlags &flags=nullptr) const
Returns information on the tables in the given schema .
QgsAbstractDatabaseProviderConnection(const QString &name)
Creates a new connection with name by reading its configuration from the settings.
This class represents a coordinate reference system (CRS).
int maxCoordinateDimensions() const
Returns the maximum coordinate dimensions of the geometries of a vector table.
void setSchema(const QString &schema)
Sets the schema.
QString comment() const
Returns the table comment.
void setGeometryColumn(const QString &geometryColumn)
Sets the geometry column name to geometryColumn.
QString schema() const
Returns the schema or an empty string for backends that do not support a schema.
Capabilities mCapabilities
Custom exception class for provider connection related exceptions.
static int coordDimensions(Type type)
Returns the coordinate dimension of the geometry type as an integer.
QVariantMap info() const
Returns additional information about the table.