16 #ifndef QGSABSTRACTDATABASEPROVIDERCONNECTION_H
17 #define QGSABSTRACTDATABASEPROVIDERCONNECTION_H
21 #include "qgis_core.h"
62 MaterializedView = 1 << 5,
67 Q_DECLARE_FLAGS( TableFlags, TableFlag )
137 SIP_PYOBJECT __next__();
139 QList<QVariant> result;
140 Py_BEGIN_ALLOW_THREADS
141 result = sipCpp->nextRow( );
143 if ( ! result.isEmpty() )
145 const sipTypeDef *qvariantlist_type = sipFindType(
"QList<QVariant>" );
146 sipRes = sipConvertFromNewType(
new QList<QVariant>( result ), qvariantlist_type, Py_None );
150 PyErr_SetString( PyExc_StopIteration,
"" );
162 struct CORE_EXPORT QueryResultIterator
SIP_SKIP
165 QVariantList nextRow();
168 bool hasNextRow()
const;
171 long long fetchedRowCount();
174 long long rowCount();
176 virtual ~QueryResultIterator() =
default;
180 virtual QVariantList nextRowPrivate() = 0;
181 virtual bool hasNextRowPrivate()
const = 0;
182 virtual long long rowCountPrivate()
const = 0;
184 mutable qlonglong mFetchedRowCount = 0;
185 mutable QMutex mMutex;
194 void appendColumn(
const QString &columnName )
SIP_SKIP;
201 QueryResult( std::shared_ptr<QueryResultIterator> iterator )
SIP_SKIP;
212 double queryExecutionTime( );
217 void setQueryExecutionTime(
double queryExecutionTime );
223 mutable std::shared_ptr<QueryResultIterator> mResultIterator;
224 QStringList mColumns;
226 double mQueryExecutionTime = 0;
249 bool disableSelectAtId =
false;
268 SIP_PYOBJECT __repr__();
270 QString
str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty: '%1'>" ).arg( sipCpp->tableName() );
271 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
282 SIP_PYOBJECT __repr__();
284 QString
str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty.GeometryColumnType: '%1, %2'>" ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType ), sipCpp->crs.authid() );
285 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
294 return this->crs == other.
crs && this->wkbType == other.
wkbType;
305 QString tableName()
const;
312 void setTableName(
const QString &name );
324 QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> geometryColumnTypes()
const;
329 void setGeometryColumnTypes(
const QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> &geometryColumnTypes );
338 QString defaultName()
const;
349 QString schema()
const;
354 void setSchema(
const QString &schema );
359 QString geometryColumn()
const;
364 void setGeometryColumn(
const QString &geometryColumn );
369 QStringList primaryKeyColumns()
const;
374 void setPrimaryKeyColumns(
const QStringList &primaryKeyColumns );
379 QList<QgsCoordinateReferenceSystem> crsList()
const;
384 TableFlags flags()
const;
389 void setFlags(
const TableFlags &flags );
394 QString comment()
const;
399 void setComment(
const QString &comment );
407 QVariantMap info()
const;
415 void setInfo(
const QVariantMap &info );
422 int geometryColumnCount()
const;
427 void setGeometryColumnCount(
int geometryColumnCount );
440 int maxCoordinateDimensions()
const;
447 QList<GeometryColumnType> mGeometryColumnTypes;
453 QString mGeometryColumn;
455 int mGeometryColumnCount;
457 QStringList mPkColumns;
480 CreateVectorTable = 1 << 1,
481 DropRasterTable = 1 << 2,
482 DropVectorTable = 1 << 3,
483 RenameVectorTable = 1 << 4,
484 RenameRasterTable = 1 << 5,
485 CreateSchema = 1 << 6,
487 RenameSchema = 1 << 8,
493 TableExists = 1 << 14,
495 CreateSpatialIndex = 1 << 16,
496 SpatialIndexExists = 1 << 17,
497 DeleteSpatialIndex = 1 << 18,
498 DeleteField = 1 << 19,
499 DeleteFieldCascade = 1 << 20,
503 Q_DECLARE_FLAGS( Capabilities, Capability )
504 Q_FLAG( Capabilities )
519 Q_ENUM( GeometryColumnCapability )
520 Q_DECLARE_FLAGS( GeometryColumnCapabilities, GeometryColumnCapability )
521 Q_FLAG( GeometryColumnCapabilities )
544 Capabilities capabilities()
const;
551 virtual GeometryColumnCapabilities geometryColumnCapabilities();
557 virtual Qgis::SqlLayerDefinitionCapabilities sqlLayerDefinitionCapabilities();
796 QString providerKey() const;
807 virtual QMultiMap<
Qgis::SqlKeywordCategory, QStringList> sqlDictionary();
818 void checkCapability(
Capability capability ) const;
821 Capabilities mCapabilities = Capabilities()
SIP_SKIP;
822 GeometryColumnCapabilities mGeometryColumnCapabilities = GeometryColumnCapabilities()
SIP_SKIP;
823 Qgis::SqlLayerDefinitionCapabilities mSqlLayerDefinitionCapabilities =
Qgis::SqlLayerDefinitionCapabilities()
SIP_SKIP;
824 QString mProviderKey;
The Qgis class provides global constants for use throughout the application.
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
GeometryColumnCapability
The GeometryColumnCapability enum represents the geomery column features supported by the connection.
Capability
The Capability enum represents the operations supported by the connection.
TableFlag
Flags for table properties.
The QgsAbstractProviderConnection provides an interface for data provider connections.
This class represents a coordinate reference system (CRS).
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
Custom exception class for provider connection related exceptions.
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
Type
The WKB type describes the number of dimensions a geometry has.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
const QgsCoordinateReferenceSystem & crs
The QueryResult class represents the result of a query executed by execSql()
QList< QList< QVariant > > rows(QgsFeedback *feedback=nullptr)
Returns the result rows by calling the iterator internally and fetching all the rows,...
long long fetchedRowCount() const
Returns the number of fetched rows.
bool hasNextRow() const
Returns true if there are more rows to fetch.
long long rowCount() const
Returns the number of rows returned by a SELECT query or Qgis::FeatureCountState::UnknownCount if unk...
QList< QVariant > nextRow() const
Returns the next result row or an empty row if there are no rows left.
QStringList columns() const
Returns the column names.
The SpatialIndexOptions contains extra options relating to spatial index creation.
QString geometryColumnName
Specifies the name of the geometry column to create the index for.
The SqlVectorLayerOptions stores all information required to create a SQL (query) layer.
QString sql
The SQL expression that defines the SQL (query) layer.
QStringList primaryKeyColumns
List of primary key column names.
QString filter
Additional subset string (provider-side filter), not all data providers support this feature: check s...
QString layerName
Optional name for the new layer.
QString geometryColumn
Name of the geometry column.
The GeometryColumnType struct represents the combination of geometry type and CRS for the table geome...
bool operator==(const GeometryColumnType &other) const
QgsWkbTypes::Type wkbType
QgsCoordinateReferenceSystem crs
The TableProperty class represents a database table or view.