mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-04 00:04:03 -04:00
1235 lines
37 KiB
Plaintext
1235 lines
37 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/providers/qgsabstractdatabaseproviderconnection.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.py again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
class QgsAbstractDatabaseProviderConnection : QgsAbstractProviderConnection
|
|
{
|
|
%Docstring(signature="appended")
|
|
Provides common functionality for database based connections.
|
|
|
|
This class performs low level DB operations without asking the user for
|
|
confirmation or handling currently opened layers and the registry
|
|
entries, it is responsibility of the client code to keep layers in sync.
|
|
The class methods will throw exceptions in case the requested operation
|
|
is not supported or cannot be performed without errors.
|
|
|
|
.. versionadded:: 3.10
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsabstractdatabaseproviderconnection.h"
|
|
%End
|
|
public:
|
|
static const QMetaObject staticMetaObject;
|
|
|
|
public:
|
|
|
|
enum class TableFlag
|
|
{
|
|
Aspatial,
|
|
Vector,
|
|
Raster,
|
|
View,
|
|
MaterializedView,
|
|
Foreign,
|
|
IncludeSystemTables,
|
|
};
|
|
|
|
typedef QFlags<QgsAbstractDatabaseProviderConnection::TableFlag> TableFlags;
|
|
|
|
|
|
struct QueryResult
|
|
{
|
|
|
|
QStringList columns() const;
|
|
%Docstring
|
|
Returns the column names.
|
|
%End
|
|
|
|
QList<QList<QVariant> > rows( QgsFeedback *feedback = 0 );
|
|
%Docstring
|
|
Returns the result rows by calling the iterator internally and fetching
|
|
all the rows, an optional ``feedback`` can be used to interrupt the
|
|
fetching loop.
|
|
|
|
.. note::
|
|
|
|
calling this function more than one time is not supported: the second
|
|
call will always return an empty list.
|
|
%End
|
|
|
|
bool hasNextRow() const;
|
|
%Docstring
|
|
Returns ``True`` if there are more rows to fetch.
|
|
|
|
.. seealso:: :py:func:`nextRow`
|
|
|
|
.. seealso:: :py:func:`rewind`
|
|
%End
|
|
|
|
QList<QVariant> nextRow() const;
|
|
%Docstring
|
|
Returns the next result row or an empty row if there are no rows left.
|
|
|
|
.. seealso:: :py:func:`hasNextRow`
|
|
|
|
.. seealso:: :py:func:`rewind`
|
|
%End
|
|
|
|
long long fetchedRowCount( ) const;
|
|
%Docstring
|
|
Returns the number of fetched rows.
|
|
|
|
.. seealso:: :py:func:`rowCount`
|
|
%End
|
|
|
|
long long rowCount( ) const;
|
|
%Docstring
|
|
Returns the number of rows returned by a SELECT query or
|
|
:py:class:`Qgis`.FeatureCountState.UnknownCount if unknown.
|
|
|
|
.. seealso:: :py:func:`fetchedRowCount`
|
|
%End
|
|
|
|
|
|
// Python iterator
|
|
QueryResult *__iter__();
|
|
%MethodCode
|
|
sipRes = sipCpp;
|
|
%End
|
|
|
|
SIP_PYOBJECT __next__();
|
|
%MethodCode
|
|
QList<QVariant> result;
|
|
Py_BEGIN_ALLOW_THREADS
|
|
result = sipCpp->nextRow( );
|
|
Py_END_ALLOW_THREADS
|
|
if ( ! result.isEmpty() )
|
|
{
|
|
const sipTypeDef *qvariantlist_type = sipFindType( "QList<QVariant>" );
|
|
sipRes = sipConvertFromNewType( new QList<QVariant>( result ), qvariantlist_type, Py_None );
|
|
}
|
|
else
|
|
{
|
|
PyErr_SetString( PyExc_StopIteration, "" );
|
|
}
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double queryExecutionTime( ) const;
|
|
%Docstring
|
|
Returns the query execution time in milliseconds.
|
|
%End
|
|
|
|
void setQueryExecutionTime( double queryExecutionTime );
|
|
%Docstring
|
|
Sets the query execution time to ``queryExecutionTime`` milliseconds.
|
|
%End
|
|
|
|
|
|
};
|
|
|
|
struct SqlVectorLayerOptions
|
|
{
|
|
QString sql;
|
|
QString filter;
|
|
QString layerName;
|
|
QStringList primaryKeyColumns;
|
|
QString geometryColumn;
|
|
bool disableSelectAtId;
|
|
|
|
};
|
|
|
|
struct TableProperty
|
|
{
|
|
|
|
SIP_PYOBJECT __repr__();
|
|
%MethodCode
|
|
QString str = QStringLiteral( "<QgsAbstractDatabaseProviderConnection.TableProperty: '%1'>" ).arg( sipCpp->tableName() );
|
|
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
|
|
%End
|
|
|
|
struct GeometryColumnType
|
|
{
|
|
SIP_PYOBJECT __repr__();
|
|
%MethodCode
|
|
QString str = QStringLiteral( "<QgsAbstractDatabaseProviderConnection.TableProperty.GeometryColumnType: '%1, %2'>" ).arg( QgsWkbTypes::displayString( sipCpp->wkbType ), sipCpp->crs.authid() );
|
|
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
|
|
%End
|
|
Qgis::WkbType wkbType;
|
|
QgsCoordinateReferenceSystem crs;
|
|
|
|
bool operator==( const GeometryColumnType &other ) const;
|
|
};
|
|
|
|
public:
|
|
|
|
QString tableName() const;
|
|
%Docstring
|
|
Returns the table name.
|
|
|
|
.. seealso:: :py:func:`defaultName`
|
|
%End
|
|
|
|
void setTableName( const QString &name );
|
|
%Docstring
|
|
Sets the table name to ``name``.
|
|
|
|
.. seealso:: :py:func:`defaultName`
|
|
%End
|
|
|
|
void addGeometryColumnType( Qgis::WkbType type, const QgsCoordinateReferenceSystem &crs );
|
|
%Docstring
|
|
Appends the geometry column ``type`` with the given ``srid`` to the
|
|
geometry column types list.
|
|
%End
|
|
|
|
QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> geometryColumnTypes() const;
|
|
%Docstring
|
|
Returns the list of geometry column types and CRSs.
|
|
|
|
The method returns a list of GeometryColumnType.
|
|
%End
|
|
|
|
void setGeometryColumnTypes( const QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> &geometryColumnTypes );
|
|
%Docstring
|
|
Sets the geometry column types to ``geometryColumnTypes``.
|
|
%End
|
|
|
|
QString defaultName() const;
|
|
%Docstring
|
|
Returns the default name for the table entry.
|
|
|
|
This is usually the table name but in case there are multiple geometry
|
|
columns, the geometry column name is appended to the table name.
|
|
|
|
.. seealso:: :py:func:`geometryColumnCount`
|
|
%End
|
|
|
|
TableProperty at( int index ) const;
|
|
%Docstring
|
|
Returns the table property corresponding to the geometry type at the
|
|
given ``index``.
|
|
%End
|
|
|
|
QString schema() const;
|
|
%Docstring
|
|
Returns the schema or an empty string for backends that do not support a
|
|
schema.
|
|
%End
|
|
|
|
void setSchema( const QString &schema );
|
|
%Docstring
|
|
Sets the ``schema``.
|
|
%End
|
|
|
|
QString geometryColumn() const;
|
|
%Docstring
|
|
Returns the geometry column name.
|
|
%End
|
|
|
|
void setGeometryColumn( const QString &geometryColumn );
|
|
%Docstring
|
|
Sets the geometry column name to ``geometryColumn``.
|
|
%End
|
|
|
|
QStringList primaryKeyColumns() const;
|
|
%Docstring
|
|
Returns the list of primary key column names.
|
|
%End
|
|
|
|
void setPrimaryKeyColumns( const QStringList &primaryKeyColumns );
|
|
%Docstring
|
|
Sets the primary key column names to ``primaryKeyColumns``.
|
|
%End
|
|
|
|
QList<QgsCoordinateReferenceSystem> crsList() const;
|
|
%Docstring
|
|
Returns the list of CRSs supported by the geometry column.
|
|
%End
|
|
|
|
TableFlags flags() const;
|
|
%Docstring
|
|
Returns the table flags.
|
|
%End
|
|
|
|
void setFlags( const TableFlags &flags );
|
|
%Docstring
|
|
Sets the table ``flags``.
|
|
%End
|
|
|
|
QString comment() const;
|
|
%Docstring
|
|
Returns the table comment.
|
|
%End
|
|
|
|
void setComment( const QString &comment );
|
|
%Docstring
|
|
Sets the table ``comment``.
|
|
%End
|
|
|
|
QVariantMap info() const;
|
|
%Docstring
|
|
Returns additional information about the table.
|
|
|
|
Provider classes may use this property to store custom bits of
|
|
information.
|
|
%End
|
|
|
|
void setInfo( const QVariantMap &info );
|
|
%Docstring
|
|
Sets additional information about the table to ``info``.
|
|
|
|
Provider classes may use this property to store custom bits of
|
|
information.
|
|
%End
|
|
|
|
int geometryColumnCount() const;
|
|
%Docstring
|
|
Returns the number of geometry columns in the original table this entry
|
|
refers to.
|
|
|
|
This information is used internally to build the :py:func:`defaultName`.
|
|
%End
|
|
|
|
void setGeometryColumnCount( int geometryColumnCount );
|
|
%Docstring
|
|
Sets the ``geometryColumnCount``.
|
|
%End
|
|
|
|
void setFlag( const TableFlag &flag );
|
|
%Docstring
|
|
Sets a ``flag``.
|
|
%End
|
|
|
|
int maxCoordinateDimensions() const;
|
|
%Docstring
|
|
Returns the maximum coordinate dimensions of the geometries of a vector
|
|
table.
|
|
|
|
This information is calculated from the geometry columns types.
|
|
|
|
.. seealso:: :py:func:`geometryColumnTypes`
|
|
%End
|
|
|
|
bool operator==( const QgsAbstractDatabaseProviderConnection::TableProperty &other ) const;
|
|
|
|
};
|
|
|
|
struct SpatialIndexOptions
|
|
{
|
|
QString geometryColumnName;
|
|
};
|
|
|
|
enum Capability
|
|
{
|
|
CreateVectorTable,
|
|
DropRasterTable,
|
|
DropVectorTable,
|
|
RenameVectorTable,
|
|
RenameRasterTable,
|
|
CreateSchema,
|
|
DropSchema,
|
|
RenameSchema,
|
|
ExecuteSql,
|
|
Vacuum,
|
|
Tables,
|
|
Schemas,
|
|
SqlLayers,
|
|
TableExists,
|
|
Spatial,
|
|
CreateSpatialIndex,
|
|
SpatialIndexExists,
|
|
DeleteSpatialIndex,
|
|
DeleteField,
|
|
DeleteFieldCascade,
|
|
AddField,
|
|
ListFieldDomains,
|
|
RetrieveFieldDomain,
|
|
SetFieldDomain,
|
|
AddFieldDomain,
|
|
RenameField,
|
|
RetrieveRelationships,
|
|
AddRelationship,
|
|
UpdateRelationship,
|
|
DeleteRelationship,
|
|
MoveTableToSchema,
|
|
};
|
|
typedef QFlags<QgsAbstractDatabaseProviderConnection::Capability> Capabilities;
|
|
|
|
|
|
enum GeometryColumnCapability
|
|
{
|
|
Z,
|
|
M,
|
|
SinglePart,
|
|
Curves,
|
|
SinglePoint,
|
|
SingleLineString,
|
|
SinglePolygon,
|
|
PolyhedralSurfaces,
|
|
};
|
|
|
|
typedef QFlags<QgsAbstractDatabaseProviderConnection::GeometryColumnCapability> GeometryColumnCapabilities;
|
|
|
|
|
|
QgsAbstractDatabaseProviderConnection( const QString &name );
|
|
%Docstring
|
|
Creates a new connection with ``name`` by reading its configuration from
|
|
the settings.
|
|
|
|
If a connection with this name cannot be found, an empty connection will
|
|
be returned.
|
|
%End
|
|
|
|
QgsAbstractDatabaseProviderConnection( const QString &uri, const QVariantMap &configuration );
|
|
%Docstring
|
|
Creates a new connection from the given ``uri`` and ``configuration``.
|
|
|
|
The connection is not automatically stored in the settings.
|
|
|
|
.. seealso:: :py:func:`store`
|
|
%End
|
|
|
|
|
|
|
|
Capabilities capabilities() const;
|
|
%Docstring
|
|
Returns connection capabilities.
|
|
|
|
.. seealso:: :py:func:`capabilities2`
|
|
%End
|
|
|
|
Qgis::DatabaseProviderConnectionCapabilities2 capabilities2() const;
|
|
%Docstring
|
|
Returns extended connection capabilities.
|
|
|
|
.. seealso:: :py:func:`capabilities`
|
|
|
|
.. versionadded:: 3.32
|
|
%End
|
|
|
|
virtual GeometryColumnCapabilities geometryColumnCapabilities();
|
|
%Docstring
|
|
Returns connection geometry column capabilities (Z, M, SinglePart,
|
|
Curves).
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
virtual Qgis::DatabaseProviderTableImportCapabilities tableImportCapabilities() const = 0;
|
|
%Docstring
|
|
Represents capabilities of the database provider connection when
|
|
importing table data.
|
|
|
|
.. versionadded:: 3.44
|
|
%End
|
|
|
|
virtual Qgis::SqlLayerDefinitionCapabilities sqlLayerDefinitionCapabilities();
|
|
%Docstring
|
|
Returns SQL layer definition capabilities (Filters, GeometryColumn,
|
|
PrimaryKeys).
|
|
|
|
.. versionadded:: 3.22
|
|
%End
|
|
|
|
|
|
virtual QString tableUri( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns the URI string for the given ``table`` and ``schema``.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.12
|
|
%End
|
|
|
|
virtual void createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, Qgis::WkbType wkbType, const QgsCoordinateReferenceSystem &srs, bool overwrite, const QMap<QString, QVariant> *options ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Creates an empty table with ``name`` in the given ``schema`` (schema is
|
|
ignored if not supported by the backend).
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
struct VectorLayerExporterOptions
|
|
{
|
|
QString layerName;
|
|
|
|
QString schema;
|
|
|
|
Qgis::WkbType wkbType;
|
|
|
|
QStringList primaryKeyColumns;
|
|
|
|
QString geometryColumn;
|
|
|
|
};
|
|
|
|
virtual QString createVectorLayerExporterDestinationUri( const QgsAbstractDatabaseProviderConnection::VectorLayerExporterOptions &options, QVariantMap &providerOptions /Out/ ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Creates a URI for use with :py:class:`QgsVectorLayerExporter`
|
|
corresponding to given destination table ``options`` for the backend.
|
|
|
|
:param options: defines the desired destination table details
|
|
|
|
:return: - destination URI for use with
|
|
:py:class:`QgsVectorLayerExporter`
|
|
- providerOptions: a map of options to pass to
|
|
:py:func:`~QgsAbstractDatabaseProviderConnection.createVectorTable`
|
|
or the provider's createEmptyTable method.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual bool tableExists( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Checks whether a table ``name`` exists in the given ``schema``.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void dropVectorTable( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Drops a vector (or aspatial) table with given ``schema`` (schema is
|
|
ignored if not supported by the backend) and ``name``.
|
|
|
|
.. note::
|
|
|
|
It is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void dropRasterTable( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Drops a raster table with given ``schema`` (schema is ignored if not
|
|
supported by the backend) and ``name``.
|
|
|
|
.. note::
|
|
|
|
It is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void renameVectorTable( const QString &schema, const QString &name, const QString &newName ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Renames a vector or aspatial table with given ``schema`` (schema is
|
|
ignored if not supported by the backend) and ``name``.
|
|
|
|
.. note::
|
|
|
|
It is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void renameRasterTable( const QString &schema, const QString &name, const QString &newName ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Renames a raster table with given ``schema`` (schema is ignored if not
|
|
supported by the backend) and ``name``.
|
|
|
|
.. note::
|
|
|
|
It is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void createSchema( const QString &name ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Creates a new schema with the specified ``name``.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void dropSchema( const QString &name, bool force = false ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Drops an entire schema with the specified name.
|
|
|
|
:param name: name of the schema to be dropped
|
|
:param force: if ``True``, a DROP CASCADE will drop all related objects
|
|
|
|
.. note::
|
|
|
|
It is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void deleteField( const QString &fieldName, const QString &schema, const QString &tableName, bool force = false ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Deletes the field with the specified name.
|
|
|
|
:param fieldName: name of the field to be deleted
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
:param force: if ``True``, a DROP CASCADE will drop all related objects
|
|
|
|
.. note::
|
|
|
|
it is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
virtual void addField( const QgsField &field, const QString &schema, const QString &tableName ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Adds a field.
|
|
|
|
:param field: specification of the new field
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
|
|
.. note::
|
|
|
|
it is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
virtual void renameField( const QString &schema, const QString &tableName, const QString &name, const QString &newName ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Renames an existing field.
|
|
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
:param name: current name of field
|
|
:param newName: new name for field
|
|
|
|
.. note::
|
|
|
|
it is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.28
|
|
%End
|
|
|
|
virtual void renameSchema( const QString &name, const QString &newName ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Renames a schema with the specified ``name``. Raises a
|
|
:py:class:`QgsProviderConnectionException` if any errors are
|
|
encountered.
|
|
|
|
.. note::
|
|
|
|
it is responsibility of the caller to handle open layers and registry entries.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual QList<QList<QVariant>> executeSql( const QString &sql, QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Executes raw ``sql`` and returns the (possibly empty) list of results in
|
|
a multi-dimensional array, optionally ``feedback`` can be provided.
|
|
|
|
.. seealso:: :py:func:`execSql`
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual QgsVectorLayer *createSqlVectorLayer( const SqlVectorLayerOptions &options ) const throw( QgsProviderConnectionException ) /Factory/;
|
|
%Docstring
|
|
Creates and returns a (possibly invalid) vector layer based on a SQL
|
|
statement and ``options``.
|
|
|
|
The
|
|
:py:func:`~QgsAbstractDatabaseProviderConnection.validateSqlVectorLayer`
|
|
method can be used in advance to test whether the options are valid for
|
|
the provider, and retrieve a user-friendly explanation if not.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered or
|
|
if SQL layer creation is not
|
|
supported.
|
|
|
|
.. seealso:: :py:func:`validateSqlVectorLayer`
|
|
|
|
.. versionadded:: 3.22
|
|
%End
|
|
|
|
virtual bool validateSqlVectorLayer( const SqlVectorLayerOptions &options, QString &message /Out/ ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Validates the SQL query ``options`` to determine if it is possible to
|
|
create a vector layer based on a SQL statement and ``options``.
|
|
|
|
The base class method returns ``True`` and does not do any checks.
|
|
|
|
:param options: SQL statement and options
|
|
|
|
:return: - ``True`` if the SQL is valid for the provider.
|
|
- message: a translated, user-friendly explanation if the SQL
|
|
is not valid for the provider.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered or
|
|
if SQL layer creation is not
|
|
supported.
|
|
|
|
.. seealso:: :py:func:`createSqlVectorLayer`
|
|
|
|
.. versionadded:: 3.44
|
|
%End
|
|
|
|
virtual SqlVectorLayerOptions sqlOptions( const QString &layerSource ) throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns the SQL layer options from a ``layerSource``.
|
|
|
|
.. note::
|
|
|
|
the default implementation returns a default constructed option object.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered or
|
|
if SQL layer creation is not
|
|
supported.
|
|
|
|
.. versionadded:: 3.22
|
|
%End
|
|
|
|
virtual QueryResult execSql( const QString &sql, QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Executes raw ``sql`` and returns the (possibly empty) query results,
|
|
optionally ``feedback`` can be provided.
|
|
|
|
.. seealso:: :py:func:`executeSql`
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.18
|
|
%End
|
|
|
|
virtual void vacuum( const QString &schema, const QString &name ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Vacuum the database table with given ``schema`` and ``name`` (schema is
|
|
ignored if not supported by the backend).
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual void createSpatialIndex( const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options = QgsAbstractDatabaseProviderConnection::SpatialIndexOptions() ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Creates a spatial index for the database table with given ``schema`` and
|
|
``name`` (schema is ignored if not supported by the backend).
|
|
|
|
The ``options`` argument can be used to provide extra options
|
|
controlling the spatial index creation.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.14
|
|
%End
|
|
|
|
virtual bool spatialIndexExists( const QString &schema, const QString &name, const QString &geometryColumn ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Determines whether a spatial index exists for the database table with
|
|
given ``schema``, ``name`` and ``geometryColumn`` (``schema`` and
|
|
``geometryColumn`` are ignored if not supported by the backend).
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.14
|
|
%End
|
|
|
|
virtual void deleteSpatialIndex( const QString &schema, const QString &name, const QString &geometryColumn ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Deletes the existing spatial index for the database table with given
|
|
``schema``, ``name`` and ``geometryColumn`` (``schema`` and
|
|
``geometryColumn`` are ignored if not supported by the backend).
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.14
|
|
%End
|
|
|
|
|
|
virtual QgsAbstractDatabaseProviderConnection::TableProperty table( const QString &schema, const QString &table, QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns information on a ``table`` in the given ``schema``.
|
|
|
|
Since QGIS 3.32 the optional ``feedback`` argument can be used to cancel
|
|
the request.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered or
|
|
if the table does not exist.
|
|
|
|
.. note::
|
|
|
|
Not available in Python bindings
|
|
|
|
.. versionadded:: 3.12
|
|
%End
|
|
|
|
QList<QgsAbstractDatabaseProviderConnection::TableProperty> tablesInt( const QString &schema = QString(), const int flags = 0 ) const throw( QgsProviderConnectionException ) /PyName=tables/;
|
|
%Docstring
|
|
Returns information on the tables in the given schema.
|
|
|
|
:param schema: name of the schema (ignored if not supported by the
|
|
backend)
|
|
:param flags: filter tables by flags, this option completely overrides
|
|
search options stored in the connection
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
|
|
|
|
virtual QStringList schemas() const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns information about the existing schemas.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
%End
|
|
|
|
virtual QgsFields fields( const QString &schema, const QString &table, QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns the fields of a ``table`` and ``schema``.
|
|
|
|
Since QGIS 3.32 the optional ``feedback`` argument can be used to cancel
|
|
the request.
|
|
|
|
.. note::
|
|
|
|
the default implementation creates a temporary vector layer, providers may
|
|
choose to override this method for a greater efficiency of to overcome provider's
|
|
behavior when the layer does not expose all fields (GPKG for example hides geometry
|
|
and primary key column).
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
virtual QList< QgsVectorDataProvider::NativeType > nativeTypes() const throw( QgsProviderConnectionException ) = 0;
|
|
%Docstring
|
|
Returns a list of native types supported by the connection.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
QString providerKey() const;
|
|
%Docstring
|
|
Returns the provider key.
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
virtual QMultiMap<Qgis::SqlKeywordCategory, QStringList> sqlDictionary();
|
|
%Docstring
|
|
Returns a dictionary of SQL keywords supported by the provider. The
|
|
default implementation returns an list of common reserved words under
|
|
the "Keyword" and "Constant" categories.
|
|
|
|
Subclasses should add provider- and/or connection- specific words.
|
|
|
|
.. versionadded:: 3.22
|
|
%End
|
|
|
|
virtual QSet< QString > illegalFieldNames() const;
|
|
%Docstring
|
|
Returns a list of field names which are considered illegal by the
|
|
connection and should not be used when creating or altering fields.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
virtual QString defaultPrimaryKeyColumnName() const;
|
|
%Docstring
|
|
Returns the default name to use for a primary key column for the
|
|
connection.
|
|
|
|
The returned name will match common practice for the database backend.
|
|
|
|
The base class method returns "pk".
|
|
|
|
.. versionadded:: 3.44
|
|
%End
|
|
|
|
virtual QString defaultGeometryColumnName() const;
|
|
%Docstring
|
|
Returns the default name to use for a geometry column for the
|
|
connection.
|
|
|
|
The returned name will match common practice for the database backend.
|
|
|
|
The base class method returns "geom".
|
|
|
|
.. versionadded:: 3.44
|
|
%End
|
|
|
|
virtual QStringList fieldDomainNames() const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns a list of field domain names present on the provider.
|
|
|
|
This is supported on providers with the Capability.ListFieldDomains
|
|
capability only.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. seealso:: :py:func:`fieldDomain`
|
|
|
|
.. versionadded:: 3.26
|
|
%End
|
|
|
|
virtual QList< Qgis::FieldDomainType > supportedFieldDomainTypes() const;
|
|
%Docstring
|
|
Returns a list of field domain types which are supported by the
|
|
provider.
|
|
|
|
.. versionadded:: 3.28
|
|
%End
|
|
|
|
virtual QgsFieldDomain *fieldDomain( const QString &name ) const throw( QgsProviderConnectionException ) /Factory/;
|
|
%Docstring
|
|
Returns the field domain with the specified ``name`` from the provider.
|
|
|
|
The caller takes ownership of the return object. Will return ``None`` if
|
|
no matching field domain is found.
|
|
|
|
This is supported on providers with the Capability.RetrieveFieldDomain
|
|
capability only.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. seealso:: :py:func:`fieldDomainNames`
|
|
|
|
.. versionadded:: 3.26
|
|
%End
|
|
|
|
virtual void setFieldDomainName( const QString &fieldName, const QString &schema, const QString &tableName, const QString &domainName ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Sets the field domain name for the existing field with the specified
|
|
name.
|
|
|
|
:param fieldName: name of the field to be modified
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
:param domainName: name of the domain to set for the field. Must be an
|
|
existing field domain (see
|
|
:py:func:`~QgsAbstractDatabaseProviderConnection.fieldDomainNames`).
|
|
Set to an empty string to remove a previously set
|
|
domain.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.26
|
|
%End
|
|
|
|
virtual void addFieldDomain( const QgsFieldDomain &domain, const QString &schema ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Adds a new field ``domain`` to the database.
|
|
|
|
:param domain: field domain to add
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.26
|
|
%End
|
|
|
|
virtual void setFieldAlias( const QString &fieldName, const QString &schema, const QString &tableName, const QString &alias ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Sets the ``alias`` for the existing field with the specified name.
|
|
|
|
:param fieldName: name of the field to be modified
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
:param alias: alias to set for the field. Set to an empty string to
|
|
remove a previously set alias.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.32
|
|
%End
|
|
|
|
virtual void setTableComment( const QString &schema, const QString &tableName, const QString &comment ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Sets the ``comment`` for the existing table with the specified name.
|
|
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
:param comment: comment to set for the table. Set to an empty string to
|
|
remove a previously set comment.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.44
|
|
%End
|
|
|
|
virtual void setFieldComment( const QString &fieldName, const QString &schema, const QString &tableName, const QString &comment ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Sets the ``comment`` for the existing field with the specified name.
|
|
|
|
:param fieldName: name of the field to be modified
|
|
:param schema: name of the schema (schema is ignored if not supported by
|
|
the backend).
|
|
:param tableName: name of the table
|
|
:param comment: comment to set for the field. Set to an empty string to
|
|
remove a previously set comment.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.32
|
|
%End
|
|
|
|
virtual void moveTableToSchema( const QString &sourceSchema, const QString &tableName, const QString &targetSchema ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Move table to a different schema.
|
|
|
|
:param sourceSchema: name of the source schema.
|
|
:param tableName: name of the table.
|
|
:param targetSchema: name of the target schema to move table to.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.44
|
|
%End
|
|
|
|
|
|
SIP_PYOBJECT supportedRelationshipCardinalities() const /TypeHint="List[Qgis.RelationshipCardinality]"/;
|
|
%Docstring
|
|
Returns a list of relationship cardinalities which are supported by the
|
|
provider.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
%MethodCode
|
|
// adapted from the qpymultimedia_qlist.sip file from the PyQt6 sources
|
|
|
|
const QList< Qgis::RelationshipCardinality > cppRes = sipCpp->supportedRelationshipCardinalities();
|
|
|
|
PyObject *l = PyList_New( cppRes.size() );
|
|
|
|
if ( !l )
|
|
sipIsErr = 1;
|
|
else
|
|
{
|
|
for ( int i = 0; i < cppRes.size(); ++i )
|
|
{
|
|
PyObject *eobj = sipConvertFromEnum( static_cast<int>( cppRes.at( i ) ),
|
|
sipType_Qgis_RelationshipCardinality );
|
|
|
|
if ( !eobj )
|
|
{
|
|
sipIsErr = 1;
|
|
}
|
|
|
|
PyList_SetItem( l, i, eobj );
|
|
}
|
|
|
|
if ( !sipIsErr )
|
|
{
|
|
sipRes = l;
|
|
}
|
|
else
|
|
{
|
|
Py_DECREF( l );
|
|
}
|
|
}
|
|
%End
|
|
|
|
SIP_PYOBJECT supportedRelationshipStrengths() const /TypeHint="List[Qgis.RelationshipStrength]"/;
|
|
%Docstring
|
|
Returns a list of relationship strengths which are supported by the
|
|
provider.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
%MethodCode
|
|
// adapted from the qpymultimedia_qlist.sip file from the PyQt6 sources
|
|
|
|
const QList< Qgis::RelationshipStrength > cppRes = sipCpp->supportedRelationshipStrengths();
|
|
|
|
PyObject *l = PyList_New( cppRes.size() );
|
|
|
|
if ( !l )
|
|
sipIsErr = 1;
|
|
else
|
|
{
|
|
for ( int i = 0; i < cppRes.size(); ++i )
|
|
{
|
|
PyObject *eobj = sipConvertFromEnum( static_cast<int>( cppRes.at( i ) ),
|
|
sipType_Qgis_RelationshipStrength );
|
|
|
|
if ( !eobj )
|
|
{
|
|
sipIsErr = 1;
|
|
}
|
|
|
|
PyList_SetItem( l, i, eobj );
|
|
}
|
|
|
|
if ( !sipIsErr )
|
|
{
|
|
sipRes = l;
|
|
}
|
|
else
|
|
{
|
|
Py_DECREF( l );
|
|
}
|
|
}
|
|
%End
|
|
|
|
virtual Qgis::RelationshipCapabilities supportedRelationshipCapabilities() const;
|
|
%Docstring
|
|
Returns the relationship capabilities supported by the provider.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
virtual QStringList relatedTableTypes() const;
|
|
%Docstring
|
|
Returns a list of the related table types supported by the database
|
|
format.
|
|
|
|
The related table type is a free-form string representing the type of
|
|
related features, where the exact interpretation is format dependent.
|
|
For instance, table types from GeoPackage relationships will directly
|
|
reflect the categories from the GeoPackage related tables extension
|
|
(i.e. "media", "simple attributes", "features", "attributes" and
|
|
"tiles").
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
virtual QList< QgsWeakRelation > relationships( const QString &schema = QString(), const QString &tableName = QString() ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Returns a list of relationships detected in the database.
|
|
|
|
This is supported on providers with the Capability.RetrieveRelationships
|
|
capability only.
|
|
|
|
If a ``schema`` and/or ``tableName`` are specified, then only
|
|
relationships where the specified table forms the left (or "parent" /
|
|
"referenced") side of the relationship are retrieved.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.28
|
|
%End
|
|
|
|
virtual void addRelationship( const QgsWeakRelation &relationship ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Adds a new field ``relationship`` to the database.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
virtual void updateRelationship( const QgsWeakRelation &relationship ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Updates an existing ``relationship`` in the database.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
virtual void deleteRelationship( const QgsWeakRelation &relationship ) const throw( QgsProviderConnectionException );
|
|
%Docstring
|
|
Deletes an existing ``relationship`` in the database.
|
|
|
|
:raises QgsProviderConnectionException: if any errors are encountered.
|
|
|
|
.. versionadded:: 3.30
|
|
%End
|
|
|
|
virtual QgsProviderSqlQueryBuilder *queryBuilder() const /Factory/;
|
|
%Docstring
|
|
Returns a SQL query builder for the connection, which provides an
|
|
interface for provider-specific creation of SQL queries.
|
|
|
|
The caller takes ownership of the returned object.
|
|
|
|
.. versionadded:: 3.28
|
|
%End
|
|
|
|
virtual QList<QgsLayerMetadataProviderResult> searchLayerMetadata( const QgsMetadataSearchContext &searchContext, const QString &searchString = QString(), const QgsRectangle &geographicExtent = QgsRectangle(), QgsFeedback *feedback = 0 ) const throw( QgsProviderConnectionException, QgsNotSupportedException );
|
|
%Docstring
|
|
Search the stored layer metadata in the connection, optionally limiting
|
|
the search to the metadata identifier, title, abstract, keywords and
|
|
categories. ``searchContext`` context for the search ``searchString``
|
|
limit the search to metadata having an extent intersecting
|
|
``geographicExtent``, an optional ``feedback`` can be used to monitor
|
|
and control the search process.
|
|
|
|
The default implementation raises a
|
|
:py:class:`QgsNotSupportedException`, data providers may implement the
|
|
search functionality.
|
|
|
|
A :py:class:`QgsProviderConnectionException` is raised in case of errors
|
|
happening during the search for providers that implement the search
|
|
functionality.
|
|
|
|
:return: a (possibly empty) list of
|
|
:py:class:`QgsLayerMetadataProviderResult`, throws a
|
|
:py:class:`QgsProviderConnectionException` if any error
|
|
occurred during the search.
|
|
|
|
:raises QgsProviderConnectionException:
|
|
|
|
:raises QgsNotSupportedException:
|
|
|
|
.. versionadded:: 3.28
|
|
%End
|
|
|
|
protected:
|
|
|
|
|
|
void checkCapability( Capability capability ) const;
|
|
%Docstring
|
|
Checks if ``capability`` is supported.
|
|
|
|
:raises QgsProviderConnectionException: if the capability is not
|
|
supported
|
|
%End
|
|
|
|
void checkCapability( Qgis::DatabaseProviderConnectionCapability2 capability ) const;
|
|
%Docstring
|
|
Checks if ``capability`` is supported.
|
|
|
|
:raises QgsProviderConnectionException: if the capability is not
|
|
supported
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
QFlags<QgsAbstractDatabaseProviderConnection::Capability> operator|(QgsAbstractDatabaseProviderConnection::Capability f1, QFlags<QgsAbstractDatabaseProviderConnection::Capability> f2);
|
|
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/providers/qgsabstractdatabaseproviderconnection.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.py again *
|
|
************************************************************************/
|