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::Tables );
138 return QList<QgsAbstractDatabaseProviderConnection::TableProperty>();
144 checkCapability( Capability::Tables );
145 const QList<QgsAbstractDatabaseProviderConnection::TableProperty> constTables {
tables( schema ) };
146 for (
const auto &t : constTables )
148 if ( t.tableName() == name )
160 return tables( schema, static_cast<QgsAbstractDatabaseProviderConnection::TableFlags>( flags ) );
166 checkCapability( Capability::Schemas );
167 return QStringList();
184 for (
const auto &t : qgis::as_const( mGeometryColumnTypes ) )
191 mGeometryColumnTypes.push_back( toAdd );
196 return mGeometryColumnTypes;
202 QString n = mTableName;
203 if ( mGeometryColumnCount > 1 ) n +=
'.' + mGeometryColumn;
211 Q_ASSERT( index >= 0 && index < mGeometryColumnTypes.size() );
213 property.mGeometryColumnTypes << mGeometryColumnTypes[ index ];
214 property.mSchema = mSchema;
215 property.mTableName = mTableName;
216 property.mGeometryColumn = mGeometryColumn;
217 property.mPkColumns = mPkColumns;
218 property.mGeometryColumnCount = mGeometryColumnCount;
219 property.mFlags = mFlags;
220 property.mComment = mComment;
221 property.mInfo = mInfo;
227 mFlags.setFlag( flag );
243 mGeometryColumnTypes = columnTypes;
249 return mGeometryColumnCount;
254 mGeometryColumnCount = geometryColumnCount;
289 QList<QgsCoordinateReferenceSystem> crss;
290 for (
const auto &t : qgis::as_const( mGeometryColumnTypes ) )
292 crss.push_back( t.crs );
304 mPkColumns = pkColumns;
309 return mGeometryColumn;
314 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 QgsAbstractDatabaseProviderConnection::TableProperty table(const QString &schema, const QString &table) const
Returns information on a table 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 QString tableUri(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Returns the URI string for the given table and schema.
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.