/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsabstractdatabaseproviderconnection.h                     *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 ************************************************************************/



class QgsAbstractDatabaseProviderConnection : QgsAbstractProviderConnection
{
%Docstring
The QgsAbstractDatabaseProviderConnection class provides common functionality
for DB 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 TableFlag
    {
      Aspatial,
      Vector,
      Raster,
      View,
      MaterializedView,
    };

    typedef QFlags<QgsAbstractDatabaseProviderConnection::TableFlag> TableFlags;


    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
          QgsWkbTypes::Type 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( const QgsWkbTypes::Type &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

It is usually the table name but in case there are multiple geometry
columns, the geometry column name is appendend 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


    };

    enum Capability
    {
      CreateVectorTable,
      DropRasterTable,
      DropVectorTable,
      RenameVectorTable,
      RenameRasterTable,
      CreateSchema,
      DropSchema,
      RenameSchema,
      ExecuteSql,
      Vacuum,
      Tables,
      Schemas,
      SqlLayers,
      TableExists,
      Spatial,
    };

    typedef QFlags<QgsAbstractDatabaseProviderConnection::Capability> Capabilities;


    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
%End


    virtual void createVectorTable( const QString &schema, const QString &name, const QgsFields &fields, QgsWkbTypes::Type 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 a QgsProviderConnectionException if any errors are encountered.

:raises :: py:class:`QgsProviderConnectionException`
%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 a QgsProviderConnectionException if any errors are encountered.

:raises :: py:class:`QgsProviderConnectionException`
%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``.
Raises a QgsProviderConnectionException if any errors are encountered.

.. note::

   it is responsibility of the caller to handle open layers and registry entries.

:raises :: py:class:`QgsProviderConnectionException`
%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``.
Raises a QgsProviderConnectionException if any errors are encountered.

.. note::

   it is responsibility of the caller to handle open layers and registry entries.

:raises :: py:class:`QgsProviderConnectionException`
%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``.
Raises a QgsProviderConnectionException if any errors are encountered.

.. note::

   it is responsibility of the caller to handle open layers and registry entries.

:raises :: py:class:`QgsProviderConnectionException`
%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``.
Raises a QgsProviderConnectionException if any errors are encountered.

.. note::

   it is responsibility of the caller to handle open layers and registry entries.

:raises :: py:class:`QgsProviderConnectionException`
%End

    virtual void createSchema( const QString &name ) const throw( QgsProviderConnectionException );
%Docstring
Creates a new schema with the specified ``name``

:raises :: py:class:`QgsProviderConnectionException`
%End

    virtual void dropSchema( const QString &name, bool force = false ) const throw( QgsProviderConnectionException );
%Docstring
Drops an entire schema with the specified name.
Raises a QgsProviderConnectionException if any errors are encountered.

: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 :: py:class:`QgsProviderConnectionException`
%End

    virtual void renameSchema( const QString &name, const QString &newName ) const throw( QgsProviderConnectionException );
%Docstring
Renames a schema with the specified ``name``.
Raises a QgsProviderConnectionException if any errors are encountered.

.. note::

   it is responsibility of the caller to handle open layers and registry entries.

:raises :: py:class:`QgsProviderConnectionException`
%End

    virtual QList<QList<QVariant>> executeSql( const QString &sql ) const throw( QgsProviderConnectionException );
%Docstring
Executes raw ``sql`` and returns the (possibly empty) list of results in a multi-dimensional array.
Raises a QgsProviderConnectionException if any errors are encountered.

:raises :: py:class:`QgsProviderConnectionException`
%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 a QgsProviderConnectionException if any errors are encountered.

:raises :: py:class:`QgsProviderConnectionException`
%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.
Raises a QgsProviderConnectionException if any errors are encountered.

: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 :: py:class:`QgsProviderConnectionException`
%End



    virtual QStringList schemas() const throw( QgsProviderConnectionException );
%Docstring
Returns information about the existing schemas.
Raises a QgsProviderConnectionException if any errors are encountered.

:raises :: py:class:`QgsProviderConnectionException`
%End

  protected:


    void checkCapability( Capability capability ) const;
%Docstring
Checks if ``capability`` is supported and throws and exception if it's not

:raises :: py:class:`QgsProviderConnectionException`
%End


};

QFlags<QgsAbstractDatabaseProviderConnection::Capability> operator|(QgsAbstractDatabaseProviderConnection::Capability f1, QFlags<QgsAbstractDatabaseProviderConnection::Capability> f2);


/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/core/qgsabstractdatabaseproviderconnection.h                     *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 ************************************************************************/