16 #ifndef QGSABSTRACTDATABASEPROVIDERCONNECTION_H
17 #define QGSABSTRACTDATABASEPROVIDERCONNECTION_H
21 #include "qgis_core.h"
62 MaterializedView = 1 << 5,
67 Q_DECLARE_FLAGS( TableFlags, TableFlag )
130 SIP_PYOBJECT __next__();
132 QList<QVariant> result;
133 Py_BEGIN_ALLOW_THREADS
134 result = sipCpp->nextRow( );
136 if ( ! result.isEmpty() )
138 const sipTypeDef *qvariantlist_type = sipFindType(
"QList<QVariant>" );
139 sipRes = sipConvertFromNewType(
new QList<QVariant>( result ), qvariantlist_type, Py_None );
143 PyErr_SetString( PyExc_StopIteration,
"" );
155 struct CORE_EXPORT QueryResultIterator
SIP_SKIP
157 QVariantList nextRow();
158 bool hasNextRow()
const;
159 qlonglong fetchedRowCount();
160 virtual ~QueryResultIterator() =
default;
164 virtual QVariantList nextRowPrivate() = 0;
165 virtual bool hasNextRowPrivate()
const = 0;
166 mutable qlonglong mFetchedRowCount = 0;
167 mutable QMutex mMutex;
175 void appendColumn(
const QString &columnName )
SIP_SKIP;
181 QueryResult( std::shared_ptr<QueryResultIterator> iterator )
SIP_SKIP;
193 mutable std::shared_ptr<QueryResultIterator> mResultIterator;
194 QStringList mColumns;
214 SIP_PYOBJECT __repr__();
216 QString str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty: '%1'>" ).arg( sipCpp->tableName() );
217 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
228 SIP_PYOBJECT __repr__();
230 QString str = QStringLiteral(
"<QgsAbstractDatabaseProviderConnection.TableProperty.GeometryColumnType: '%1, %2'>" ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType ), sipCpp->crs.authid() );
231 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
239 return this->crs == other.
crs && this->wkbType == other.
wkbType;
249 QString tableName()
const;
255 void setTableName(
const QString &name );
266 QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> geometryColumnTypes()
const;
271 void setGeometryColumnTypes(
const QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> &geometryColumnTypes );
280 QString defaultName()
const;
291 QString schema()
const;
296 void setSchema(
const QString &schema );
301 QString geometryColumn()
const;
306 void setGeometryColumn(
const QString &geometryColumn );
311 QStringList primaryKeyColumns()
const;
316 void setPrimaryKeyColumns(
const QStringList &primaryKeyColumns );
321 QList<QgsCoordinateReferenceSystem> crsList()
const;
326 TableFlags flags()
const;
331 void setFlags(
const TableFlags &flags );
336 QString comment()
const;
341 void setComment(
const QString &comment );
349 QVariantMap info()
const;
357 void setInfo(
const QVariantMap &info );
364 int geometryColumnCount()
const;
369 void setGeometryColumnCount(
int geometryColumnCount );
381 int maxCoordinateDimensions()
const;
388 QList<GeometryColumnType> mGeometryColumnTypes;
394 QString mGeometryColumn;
396 int mGeometryColumnCount;
398 QStringList mPkColumns;
410 CreateVectorTable = 1 << 1,
411 DropRasterTable = 1 << 2,
412 DropVectorTable = 1 << 3,
413 RenameVectorTable = 1 << 4,
414 RenameRasterTable = 1 << 5,
415 CreateSchema = 1 << 6,
417 RenameSchema = 1 << 8,
423 TableExists = 1 << 14,
425 CreateSpatialIndex = 1 << 16,
426 SpatialIndexExists = 1 << 17,
427 DeleteSpatialIndex = 1 << 18,
428 DeleteField = 1 << 19,
429 DeleteFieldCascade = 1 << 20,
433 Q_DECLARE_FLAGS( Capabilities, Capability )
434 Q_FLAG( Capabilities )
448 Q_ENUM( GeometryColumnCapability )
449 Q_DECLARE_FLAGS( GeometryColumnCapabilities, GeometryColumnCapability )
450 Q_FLAG( GeometryColumnCapabilities )
471 Capabilities capabilities()
const;
477 virtual GeometryColumnCapabilities geometryColumnCapabilities();
710 QString providerKey() const;
720 void checkCapability(
Capability capability ) const;
723 Capabilities mCapabilities = Capabilities()
SIP_SKIP;
724 GeometryColumnCapabilities mGeometryColumnCapabilities = GeometryColumnCapabilities()
SIP_SKIP;
725 QString mProviderKey;
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.
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,...
bool hasNextRow() const
Returns true if there are more rows to fetch.
qlonglong fetchedRowCount() const
Returns the number of fetched rows.
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.
Contains extra options relating to spatial index creation.
QString geometryColumnName
Specifies the name of the geometry column to create the index for.
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.