16 #ifndef QGSABSTRACTDATABASEPROVIDERCONNECTION_H
17 #define QGSABSTRACTDATABASEPROVIDERCONNECTION_H
21 #include "qgis_core.h"
63 MaterializedView = 1 << 5,
68 Q_DECLARE_FLAGS( TableFlags, TableFlag )
138 SIP_PYOBJECT __next__();
140 QList<QVariant> result;
141 Py_BEGIN_ALLOW_THREADS
142 result = sipCpp->nextRow( );
144 if ( ! result.isEmpty() )
146 const sipTypeDef *qvariantlist_type = sipFindType(
"QList<QVariant>" );
147 sipRes = sipConvertFromNewType(
new QList<QVariant>( result ), qvariantlist_type, Py_None );
151 PyErr_SetString( PyExc_StopIteration,
"" );
163 struct CORE_EXPORT QueryResultIterator
SIP_SKIP
166 QVariantList nextRow();
169 bool hasNextRow()
const;
172 long long fetchedRowCount();
175 long long rowCount();
177 virtual ~QueryResultIterator() =
default;
181 virtual QVariantList nextRowPrivate() = 0;
182 virtual bool hasNextRowPrivate()
const = 0;
183 virtual long long rowCountPrivate()
const = 0;
185 mutable qlonglong mFetchedRowCount = 0;
186 mutable QMutex mMutex;
195 void appendColumn(
const QString &columnName )
SIP_SKIP;
202 QueryResult( std::shared_ptr<QueryResultIterator> iterator )
SIP_SKIP;
213 double queryExecutionTime( )
const;
218 void setQueryExecutionTime(
double queryExecutionTime );
224 mutable std::shared_ptr<QueryResultIterator> mResultIterator;
225 QStringList mColumns;
227 double mQueryExecutionTime = 0;
250 bool disableSelectAtId =
false;
269 SIP_PYOBJECT __repr__();
271 QString
str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty: '%1'>" ).arg( sipCpp->tableName() );
272 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
283 SIP_PYOBJECT __repr__();
285 QString
str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty.GeometryColumnType: '%1, %2'>" ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType ), sipCpp->crs.authid() );
286 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
295 return this->crs == other.
crs && this->wkbType == other.
wkbType;
306 QString tableName()
const;
313 void setTableName(
const QString &name );
325 QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> geometryColumnTypes()
const;
330 void setGeometryColumnTypes(
const QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> &geometryColumnTypes );
339 QString defaultName()
const;
350 QString schema()
const;
355 void setSchema(
const QString &schema );
360 QString geometryColumn()
const;
365 void setGeometryColumn(
const QString &geometryColumn );
370 QStringList primaryKeyColumns()
const;
375 void setPrimaryKeyColumns(
const QStringList &primaryKeyColumns );
380 QList<QgsCoordinateReferenceSystem> crsList()
const;
385 TableFlags flags()
const;
390 void setFlags(
const TableFlags &flags );
395 QString comment()
const;
400 void setComment(
const QString &comment );
408 QVariantMap info()
const;
416 void setInfo(
const QVariantMap &info );
423 int geometryColumnCount()
const;
428 void setGeometryColumnCount(
int geometryColumnCount );
441 int maxCoordinateDimensions()
const;
448 QList<GeometryColumnType> mGeometryColumnTypes;
454 QString mGeometryColumn;
456 int mGeometryColumnCount;
458 QStringList mPkColumns;
481 CreateVectorTable = 1 << 1,
482 DropRasterTable = 1 << 2,
483 DropVectorTable = 1 << 3,
484 RenameVectorTable = 1 << 4,
485 RenameRasterTable = 1 << 5,
486 CreateSchema = 1 << 6,
488 RenameSchema = 1 << 8,
494 TableExists = 1 << 14,
496 CreateSpatialIndex = 1 << 16,
497 SpatialIndexExists = 1 << 17,
498 DeleteSpatialIndex = 1 << 18,
499 DeleteField = 1 << 19,
500 DeleteFieldCascade = 1 << 20,
502 ListFieldDomains = 1 << 22,
503 RetrieveFieldDomain = 1 << 23,
504 SetFieldDomain = 1 << 24,
505 AddFieldDomain = 1 << 25,
508 Q_DECLARE_FLAGS( Capabilities, Capability )
509 Q_FLAG( Capabilities )
524 Q_ENUM( GeometryColumnCapability )
525 Q_DECLARE_FLAGS( GeometryColumnCapabilities, GeometryColumnCapability )
526 Q_FLAG( GeometryColumnCapabilities )
549 Capabilities capabilities()
const;
556 virtual GeometryColumnCapabilities geometryColumnCapabilities();
562 virtual Qgis::SqlLayerDefinitionCapabilities sqlLayerDefinitionCapabilities();
801 QString providerKey() const;
812 virtual QMultiMap<
Qgis::SqlKeywordCategory, QStringList> sqlDictionary();
873 void checkCapability(
Capability capability ) const;
876 Capabilities mCapabilities = Capabilities()
SIP_SKIP;
877 GeometryColumnCapabilities mGeometryColumnCapabilities = GeometryColumnCapabilities()
SIP_SKIP;
878 Qgis::SqlLayerDefinitionCapabilities mSqlLayerDefinitionCapabilities =
Qgis::SqlLayerDefinitionCapabilities()
SIP_SKIP;
879 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.
Base class for field domains.
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.