1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114
|
/************************************************************************
* 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")
The :py:class:`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 class TableFlag /BaseType=IntFlag/
{
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 /BaseType=IntEnum/
{
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,
};
typedef QFlags<QgsAbstractDatabaseProviderConnection::Capability> Capabilities;
enum GeometryColumnCapability /BaseType=IntEnum/
{
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::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
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 the
``sql`` statement and optional ``options``.
:raises QgsProviderConnectionException: if any errors are encountered or
if SQL layer creation is not
supported.
.. versionadded:: 3.22
%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 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 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
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 *
************************************************************************/
|