16#ifndef QGSABSTRACTDATABASEPROVIDERCONNECTION_H
17#define QGSABSTRACTDATABASEPROVIDERCONNECTION_H
66 MaterializedView = 1 << 5,
68 IncludeSystemTables = 1 << 7,
72 Q_DECLARE_FLAGS( TableFlags, TableFlag )
142 SIP_PYOBJECT __next__();
144 QList<QVariant> result;
145 Py_BEGIN_ALLOW_THREADS
146 result = sipCpp->nextRow( );
148 if ( ! result.isEmpty() )
150 const sipTypeDef *qvariantlist_type = sipFindType(
"QList<QVariant>" );
151 sipRes = sipConvertFromNewType(
new QList<QVariant>( result ), qvariantlist_type, Py_None );
155 PyErr_SetString( PyExc_StopIteration,
"" );
167 struct CORE_EXPORT QueryResultIterator
SIP_SKIP
170 QVariantList nextRow();
173 bool hasNextRow()
const;
176 long long fetchedRowCount();
179 long long rowCount();
181 virtual ~QueryResultIterator() =
default;
185 virtual QVariantList nextRowPrivate() = 0;
186 virtual bool hasNextRowPrivate()
const = 0;
187 virtual long long rowCountPrivate()
const = 0;
189 mutable qlonglong mFetchedRowCount = 0;
190 mutable QMutex mMutex;
199 void appendColumn(
const QString &columnName )
SIP_SKIP;
206 QueryResult( std::shared_ptr<QueryResultIterator> iterator )
SIP_SKIP;
217 double queryExecutionTime( )
const;
222 void setQueryExecutionTime(
double queryExecutionTime );
228 mutable std::shared_ptr<QueryResultIterator> mResultIterator;
229 QStringList mColumns;
231 double mQueryExecutionTime = 0;
254 bool disableSelectAtId =
false;
273 SIP_PYOBJECT __repr__();
275 QString
str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty: '%1'>" ).arg( sipCpp->tableName() );
276 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
287 SIP_PYOBJECT __repr__();
289 QString
str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty.GeometryColumnType: '%1, %2'>" ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType ), sipCpp->crs.authid() );
290 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
299 return this->crs == other.
crs && this->wkbType == other.
wkbType;
310 QString tableName()
const;
317 void setTableName(
const QString &name );
329 QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> geometryColumnTypes()
const;
334 void setGeometryColumnTypes(
const QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> &geometryColumnTypes );
343 QString defaultName()
const;
354 QString schema()
const;
359 void setSchema(
const QString &schema );
364 QString geometryColumn()
const;
369 void setGeometryColumn(
const QString &geometryColumn );
374 QStringList primaryKeyColumns()
const;
379 void setPrimaryKeyColumns(
const QStringList &primaryKeyColumns );
384 QList<QgsCoordinateReferenceSystem> crsList()
const;
389 TableFlags flags()
const;
394 void setFlags(
const TableFlags &flags );
399 QString comment()
const;
404 void setComment(
const QString &comment );
412 QVariantMap info()
const;
420 void setInfo(
const QVariantMap &info );
427 int geometryColumnCount()
const;
432 void setGeometryColumnCount(
int geometryColumnCount );
445 int maxCoordinateDimensions()
const;
452 QList<GeometryColumnType> mGeometryColumnTypes;
458 QString mGeometryColumn;
460 int mGeometryColumnCount;
462 QStringList mPkColumns;
485 CreateVectorTable = 1 << 1,
486 DropRasterTable = 1 << 2,
487 DropVectorTable = 1 << 3,
488 RenameVectorTable = 1 << 4,
489 RenameRasterTable = 1 << 5,
490 CreateSchema = 1 << 6,
492 RenameSchema = 1 << 8,
498 TableExists = 1 << 14,
500 CreateSpatialIndex = 1 << 16,
501 SpatialIndexExists = 1 << 17,
502 DeleteSpatialIndex = 1 << 18,
503 DeleteField = 1 << 19,
504 DeleteFieldCascade = 1 << 20,
506 ListFieldDomains = 1 << 22,
507 RetrieveFieldDomain = 1 << 23,
508 SetFieldDomain = 1 << 24,
509 AddFieldDomain = 1 << 25,
510 RenameField = 1 << 26,
511 RetrieveRelationships = 1 << 27,
512 AddRelationship = 1 << 28,
513 UpdateRelationship = 1 << 29,
514 DeleteRelationship = 1 << 30,
517 Q_DECLARE_FLAGS( Capabilities, Capability )
518 Q_FLAG( Capabilities )
531 SinglePoint = 1 << 5,
532 SingleLineString = 1 << 6,
533 SinglePolygon = 1 << 7,
537 Q_ENUM( GeometryColumnCapability )
538 Q_DECLARE_FLAGS( GeometryColumnCapabilities, GeometryColumnCapability )
539 Q_FLAG( GeometryColumnCapabilities )
562 Capabilities capabilities()
const;
569 virtual GeometryColumnCapabilities geometryColumnCapabilities();
575 virtual Qgis::SqlLayerDefinitionCapabilities sqlLayerDefinitionCapabilities();
829 QString providerKey() const;
840 virtual QMultiMap<
Qgis::SqlKeywordCategory, QStringList> sqlDictionary();
848 virtual QSet< QString > illegalFieldNames() const;
867 virtual QList<
Qgis::FieldDomainType > supportedFieldDomainTypes() const;
913 virtual QList< Qgis::RelationshipCardinality > supportedRelationshipCardinalities()
const;
915 SIP_PYOBJECT supportedRelationshipCardinalities() const
SIP_TYPEHINT( List[
Qgis.RelationshipCardinality] );
919 const QList<
Qgis::RelationshipCardinality > cppRes = sipCpp->supportedRelationshipCardinalities();
921 PyObject *l = PyList_New( cppRes.size() );
927 for (
int i = 0; i < cppRes.size(); ++i )
929 PyObject *eobj = sipConvertFromEnum(
static_cast<int>( cppRes.at( i ) ),
930 sipType_Qgis_RelationshipCardinality );
937 PyList_SetItem( l, i, eobj );
958 virtual QList< Qgis::RelationshipStrength > supportedRelationshipStrengths()
const;
960 SIP_PYOBJECT supportedRelationshipStrengths() const
SIP_TYPEHINT( List[
Qgis.RelationshipStrength] );
964 const QList<
Qgis::RelationshipStrength > cppRes = sipCpp->supportedRelationshipStrengths();
966 PyObject *l = PyList_New( cppRes.size() );
972 for (
int i = 0; i < cppRes.size(); ++i )
974 PyObject *eobj = sipConvertFromEnum(
static_cast<int>( cppRes.at( i ) ),
975 sipType_Qgis_RelationshipStrength );
982 PyList_SetItem( l, i, eobj );
1002 virtual Qgis::RelationshipCapabilities supportedRelationshipCapabilities()
const;
1014 virtual QStringList relatedTableTypes()
const;
1094 void checkCapability(
Capability capability ) const;
1098 GeometryColumnCapabilities mGeometryColumnCapabilities = GeometryColumnCapabilities()
SIP_SKIP;
1099 Qgis::SqlLayerDefinitionCapabilities mSqlLayerDefinitionCapabilities =
Qgis::SqlLayerDefinitionCapabilities()
SIP_SKIP;
1100 QString mProviderKey;
The Qgis class provides global constants for use throughout the application.
WkbType
The WKB type describes the number of dimensions a geometry has.
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 which is raised when an operation is not supported.
Custom exception class for provider connection related exceptions.
Provides an interface for provider-specific creation of SQL queries.
A rectangle specified with double values.
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
static QString displayString(Qgis::WkbType type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
#define SIP_TYPEHINT(type)
#define SIP_THROW(name,...)
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.
QList< QVariant > nextRow() const
Returns the next result row or an empty row if there are no rows left.
long long rowCount() const
Returns the number of rows returned by a SELECT query or Qgis::FeatureCountState::UnknownCount if unk...
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
QgsCoordinateReferenceSystem crs
The TableProperty class represents a database table or view.