QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsabstractdatabaseproviderconnection.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsabstractdatabaseproviderconnection.cpp - QgsAbstractDatabaseProviderConnection
3 
4  ---------------------
5  begin : 2.8.2019
6  copyright : (C) 2019 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
17 #include "qgsvectorlayer.h"
18 #include "qgsexception.h"
19 #include "qgslogger.h"
20 #include <QVariant>
21 #include <QObject>
22 
25 {
26 
27 }
28 
29 QgsAbstractDatabaseProviderConnection::QgsAbstractDatabaseProviderConnection( const QString &uri, const QVariantMap &configuration ):
30  QgsAbstractProviderConnection( uri, configuration )
31 {
32 
33 }
34 QgsAbstractDatabaseProviderConnection::Capabilities QgsAbstractDatabaseProviderConnection::capabilities() const
35 {
36  return mCapabilities;
37 }
38 
39 QgsAbstractDatabaseProviderConnection::GeometryColumnCapabilities QgsAbstractDatabaseProviderConnection::geometryColumnCapabilities()
40 {
42 }
43 
44 QString QgsAbstractDatabaseProviderConnection::tableUri( const QString &schema, const QString &name ) const
45 {
46  Q_UNUSED( schema )
47  Q_UNUSED( name )
48  throw QgsProviderConnectionException( QObject::tr( "Operation 'tableUri' is not supported" ) );
49 }
50 
52 void QgsAbstractDatabaseProviderConnection::checkCapability( QgsAbstractDatabaseProviderConnection::Capability capability ) const
53 {
54  if ( ! mCapabilities.testFlag( capability ) )
55  {
56  static QMetaEnum metaEnum = QMetaEnum::fromType<QgsAbstractDatabaseProviderConnection::Capability>();
57  const QString capName { metaEnum.valueToKey( capability ) };
58  throw QgsProviderConnectionException( QObject::tr( "Operation '%1' is not supported for this connection" ).arg( capName ) );
59  }
60 }
61 
63 {
64  return mProviderKey;
65 }
67 
69  const QString &name,
70  const QgsFields &fields,
71  QgsWkbTypes::Type wkbType,
73  bool overwrite,
74  const QMap<QString, QVariant> *
75  options ) const
76 {
77  Q_UNUSED( schema );
78  Q_UNUSED( name );
79  Q_UNUSED( fields );
80  Q_UNUSED( srs );
81  Q_UNUSED( overwrite );
82  Q_UNUSED( options );
83  Q_UNUSED( wkbType );
84  throw QgsProviderConnectionException( QObject::tr( "Operation 'createVectorTable' is not supported" ) );
85 }
86 
87 void QgsAbstractDatabaseProviderConnection::renameVectorTable( const QString &, const QString &, const QString & ) const
88 {
89  checkCapability( Capability::RenameVectorTable );
90 }
91 
92 void QgsAbstractDatabaseProviderConnection::renameRasterTable( const QString &, const QString &, const QString & ) const
93 {
94  checkCapability( Capability::RenameRasterTable );
95 }
96 
97 void QgsAbstractDatabaseProviderConnection::dropVectorTable( const QString &, const QString & ) const
98 {
99  checkCapability( Capability::DropVectorTable );
100 }
101 
102 bool QgsAbstractDatabaseProviderConnection::tableExists( const QString &schema, const QString &name ) const
103 {
104  checkCapability( Capability::TableExists );
105  const QList<QgsAbstractDatabaseProviderConnection::TableProperty> constTables { tables( schema ) };
106  for ( const auto &t : constTables )
107  {
108  if ( t.tableName() == name )
109  {
110  return true;
111  }
112  }
113  return false;
114 }
115 
116 void QgsAbstractDatabaseProviderConnection::dropRasterTable( const QString &, const QString & ) const
117 {
118  checkCapability( Capability::DropRasterTable );
119 }
120 
122 {
123  checkCapability( Capability::CreateSchema );
124 }
125 
126 void QgsAbstractDatabaseProviderConnection::dropSchema( const QString &, bool ) const
127 {
128  checkCapability( Capability::DropSchema );
129 }
130 
131 void QgsAbstractDatabaseProviderConnection::renameSchema( const QString &, const QString & ) const
132 {
133  checkCapability( Capability::RenameSchema );
134 }
135 
136 QList<QList<QVariant>> QgsAbstractDatabaseProviderConnection::executeSql( const QString &, QgsFeedback * ) const
137 {
138  checkCapability( Capability::ExecuteSql );
139  return QList<QList<QVariant>>();
140 }
141 
142 void QgsAbstractDatabaseProviderConnection::vacuum( const QString &, const QString & ) const
143 {
144  checkCapability( Capability::Vacuum );
145 }
146 
148 {
149  checkCapability( Capability::CreateSpatialIndex );
150 }
151 
152 void QgsAbstractDatabaseProviderConnection::deleteSpatialIndex( const QString &, const QString &, const QString & ) const
153 {
154  checkCapability( Capability::DeleteSpatialIndex );
155 }
156 
157 bool QgsAbstractDatabaseProviderConnection::spatialIndexExists( const QString &, const QString &, const QString & ) const
158 {
159  checkCapability( Capability::SpatialIndexExists );
160  return false;
161 }
162 
163 void QgsAbstractDatabaseProviderConnection::deleteField( const QString &fieldName, const QString &schema, const QString &tableName, bool ) const
164 {
165  checkCapability( Capability::DeleteField );
166 
167  QgsVectorLayer::LayerOptions options { false, false };
168  options.skipCrsValidation = true;
169  std::unique_ptr<QgsVectorLayer> vl { qgis::make_unique<QgsVectorLayer>( tableUri( schema, tableName ), QStringLiteral( "temp_layer" ), mProviderKey, options ) };
170  if ( ! vl->isValid() )
171  {
172  throw QgsProviderConnectionException( QObject::tr( "Could not create a vector layer for table '%1' in schema '%2'" )
173  .arg( tableName, schema ) );
174  }
175  if ( vl->fields().lookupField( fieldName ) == -1 )
176  {
177  throw QgsProviderConnectionException( QObject::tr( "Could not find field '%1' in table '%2' in schema '%3'" )
178  .arg( fieldName, tableName, schema ) );
179 
180  }
181  if ( ! vl->dataProvider()->deleteAttributes( { vl->fields().lookupField( fieldName ) } ) )
182  {
183  throw QgsProviderConnectionException( QObject::tr( "Unknown error deleting field '%1' in table '%2' in schema '%3'" )
184  .arg( fieldName, tableName, schema ) );
185  }
186 }
187 
188 void QgsAbstractDatabaseProviderConnection::addField( const QgsField &field, const QString &schema, const QString &tableName ) const
189 {
190  checkCapability( Capability::AddField );
191 
192  QgsVectorLayer::LayerOptions options { false, false };
193  options.skipCrsValidation = true;
194  std::unique_ptr<QgsVectorLayer> vl( qgis::make_unique<QgsVectorLayer>( tableUri( schema, tableName ), QStringLiteral( "temp_layer" ), mProviderKey, options ) );
195  if ( ! vl->isValid() )
196  {
197  throw QgsProviderConnectionException( QObject::tr( "Could not create a vector layer for table '%1' in schema '%2'" )
198  .arg( tableName, schema ) );
199  }
200  if ( vl->fields().lookupField( field.name() ) != -1 )
201  {
202  throw QgsProviderConnectionException( QObject::tr( "Field '%1' in table '%2' in schema '%3' already exists" )
203  .arg( field.name(), tableName, schema ) );
204 
205  }
206  if ( ! vl->dataProvider()->addAttributes( { field } ) )
207  {
208  throw QgsProviderConnectionException( QObject::tr( "Unknown error adding field '%1' in table '%2' in schema '%3'" )
209  .arg( field.name(), tableName, schema ) );
210  }
211 }
212 
213 QList<QgsAbstractDatabaseProviderConnection::TableProperty> QgsAbstractDatabaseProviderConnection::tables( const QString &, const QgsAbstractDatabaseProviderConnection::TableFlags & ) const
214 {
215  checkCapability( Capability::Tables );
216  return QList<QgsAbstractDatabaseProviderConnection::TableProperty>();
217 }
218 
219 
221 {
222  checkCapability( Capability::Tables );
223  const QList<QgsAbstractDatabaseProviderConnection::TableProperty> constTables { tables( schema ) };
224  for ( const auto &t : constTables )
225  {
226  if ( t.tableName() == name )
227  {
228  return t;
229  }
230  }
231  throw QgsProviderConnectionException( QObject::tr( "Table '%1' was not found in schema '%2'" )
232  .arg( name, schema ) );
233 }
234 
235 QList<QgsAbstractDatabaseProviderConnection::TableProperty> QgsAbstractDatabaseProviderConnection::tablesInt( const QString &schema, const int flags ) const
236 {
237  return tables( schema, static_cast<QgsAbstractDatabaseProviderConnection::TableFlags>( flags ) );
238 }
239 
240 
242 {
243  checkCapability( Capability::Schemas );
244  return QStringList();
245 }
246 
248 {
249  return mTableName;
250 }
251 
253 {
254  mTableName = name;
255 }
256 
258 {
259  // Do not add the type if it's already present
261  for ( const auto &t : qgis::as_const( mGeometryColumnTypes ) )
262  {
263  if ( t == toAdd )
264  {
265  return;
266  }
267  }
268  mGeometryColumnTypes.push_back( toAdd );
269 }
270 
271 QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> QgsAbstractDatabaseProviderConnection::TableProperty::geometryColumnTypes() const
272 {
273  return mGeometryColumnTypes;
274 }
275 
276 QgsFields QgsAbstractDatabaseProviderConnection::fields( const QString &schema, const QString &tableName ) const
277 {
278  QgsVectorLayer::LayerOptions options { false, true };
279  options.skipCrsValidation = true;
280  QgsVectorLayer vl { tableUri( schema, tableName ), QStringLiteral( "temp_layer" ), mProviderKey, options };
281  if ( vl.isValid() )
282  {
283  return vl.fields();
284  }
285  else
286  {
287  throw QgsProviderConnectionException( QObject::tr( "Error retrieving fields information for uri: %1" ).arg( vl.publicSource() ) );
288  }
289 }
290 
292 {
293  QString n = mTableName;
294  if ( mGeometryColumnCount > 1 ) n += '.' + mGeometryColumn;
295  return n;
296 }
297 
299 {
300  TableProperty property;
301 
302  Q_ASSERT( index >= 0 && index < mGeometryColumnTypes.size() );
303 
304  property.mGeometryColumnTypes << mGeometryColumnTypes[ index ];
305  property.mSchema = mSchema;
306  property.mTableName = mTableName;
307  property.mGeometryColumn = mGeometryColumn;
308  property.mPkColumns = mPkColumns;
309  property.mGeometryColumnCount = mGeometryColumnCount;
310  property.mFlags = mFlags;
311  property.mComment = mComment;
312  property.mInfo = mInfo;
313  return property;
314 }
315 
317 {
318  mFlags.setFlag( flag );
319 }
320 
322 {
323  int res = 0;
324  for ( const TableProperty::GeometryColumnType &ct : qgis::as_const( mGeometryColumnTypes ) )
325  {
326  res = std::max( res, QgsWkbTypes::coordDimensions( ct.wkbType ) );
327  }
328  return res;
329 }
330 
332 {
333  return mSchema == other.mSchema &&
334  mTableName == other.mTableName &&
335  mGeometryColumn == other.mGeometryColumn &&
336  mGeometryColumnCount == other.mGeometryColumnCount &&
337  mPkColumns == other.mPkColumns &&
338  mFlags == other.mFlags &&
339  mComment == other.mComment &&
340  mInfo == other.mInfo;
341 }
342 
343 
344 void QgsAbstractDatabaseProviderConnection::TableProperty::setGeometryColumnTypes( const QList<QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType> &columnTypes )
345 {
346  mGeometryColumnTypes = columnTypes;
347 }
348 
349 
351 {
352  return mGeometryColumnCount;
353 }
354 
356 {
357  mGeometryColumnCount = geometryColumnCount;
358 }
359 
361 {
362  return mInfo;
363 }
364 
366 {
367  mInfo = info;
368 }
369 
371 {
372  return mComment;
373 }
374 
376 {
377  mComment = comment;
378 }
379 
380 QgsAbstractDatabaseProviderConnection::TableFlags QgsAbstractDatabaseProviderConnection::TableProperty::flags() const
381 {
382  return mFlags;
383 }
384 
385 void QgsAbstractDatabaseProviderConnection::TableProperty::setFlags( const QgsAbstractDatabaseProviderConnection::TableFlags &flags )
386 {
387  mFlags = flags;
388 }
389 
390 QList<QgsCoordinateReferenceSystem> QgsAbstractDatabaseProviderConnection::TableProperty::crsList() const
391 {
392  QList<QgsCoordinateReferenceSystem> crss;
393  for ( const auto &t : qgis::as_const( mGeometryColumnTypes ) )
394  {
395  crss.push_back( t.crs );
396  }
397  return crss;
398 }
399 
401 {
402  return mPkColumns;
403 }
404 
406 {
407  mPkColumns = pkColumns;
408 }
409 
411 {
412  return mGeometryColumn;
413 }
414 
416 {
417  mGeometryColumn = geometryColumn;
418 }
419 
421 {
422  return mSchema;
423 }
424 
426 {
427  mSchema = schema;
428 }
429 
QgsAbstractDatabaseProviderConnection::TableProperty::setGeometryColumnTypes
void setGeometryColumnTypes(const QList< QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType > &geometryColumnTypes)
Sets the geometry column types to geometryColumnTypes.
Definition: qgsabstractdatabaseproviderconnection.cpp:344
QgsAbstractDatabaseProviderConnection::createSpatialIndex
virtual void createSpatialIndex(const QString &schema, const QString &name, const QgsAbstractDatabaseProviderConnection::SpatialIndexOptions &options=QgsAbstractDatabaseProviderConnection::SpatialIndexOptions()) const SIP_THROW(QgsProviderConnectionException)
Creates a spatial index for the database table with given schema and name (schema is ignored if not s...
Definition: qgsabstractdatabaseproviderconnection.cpp:147
QgsAbstractDatabaseProviderConnection::TableProperty::setSchema
void setSchema(const QString &schema)
Sets the schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:425
QgsAbstractDatabaseProviderConnection::tablesInt
QList< QgsAbstractDatabaseProviderConnection::TableProperty > tablesInt(const QString &schema=QString(), const int flags=0) const SIP_THROW(QgsProviderConnectionException)
Returns information on the tables in the given schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:235
QgsAbstractDatabaseProviderConnection::renameRasterTable
virtual void renameRasterTable(const QString &schema, const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException)
Renames a raster table with given schema (schema is ignored if not supported by the backend) and name...
Definition: qgsabstractdatabaseproviderconnection.cpp:92
QgsAbstractDatabaseProviderConnection::dropSchema
virtual void dropSchema(const QString &name, bool force=false) const SIP_THROW(QgsProviderConnectionException)
Drops an entire schema with the specified name.
Definition: qgsabstractdatabaseproviderconnection.cpp:126
QgsAbstractDatabaseProviderConnection::createSchema
virtual void createSchema(const QString &name) const SIP_THROW(QgsProviderConnectionException)
Creates a new schema with the specified name.
Definition: qgsabstractdatabaseproviderconnection.cpp:121
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:51
QgsAbstractDatabaseProviderConnection::TableProperty::setPrimaryKeyColumns
void setPrimaryKeyColumns(const QStringList &primaryKeyColumns)
Sets the primary key column names to primaryKeyColumns.
Definition: qgsabstractdatabaseproviderconnection.cpp:405
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsAbstractDatabaseProviderConnection::spatialIndexExists
virtual bool spatialIndexExists(const QString &schema, const QString &name, const QString &geometryColumn) const SIP_THROW(QgsProviderConnectionException)
Determines whether a spatial index exists for the database table with given schema,...
Definition: qgsabstractdatabaseproviderconnection.cpp:157
QgsAbstractDatabaseProviderConnection::TableProperty::geometryColumn
QString geometryColumn() const
Returns the geometry column name.
Definition: qgsabstractdatabaseproviderconnection.cpp:410
QgsAbstractDatabaseProviderConnection::addField
virtual void addField(const QgsField &field, const QString &schema, const QString &tableName) const SIP_THROW(QgsProviderConnectionException)
Adds a field Raises a QgsProviderConnectionException if any errors are encountered.
Definition: qgsabstractdatabaseproviderconnection.cpp:188
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QgsAbstractDatabaseProviderConnection::TableProperty::primaryKeyColumns
QStringList primaryKeyColumns() const
Returns the list of primary key column names.
Definition: qgsabstractdatabaseproviderconnection.cpp:400
QgsAbstractDatabaseProviderConnection::tables
virtual QList< QgsAbstractDatabaseProviderConnection::TableProperty > tables(const QString &schema=QString(), const QgsAbstractDatabaseProviderConnection::TableFlags &flags=QgsAbstractDatabaseProviderConnection::TableFlags()) const
Returns information on the tables in the given schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:213
QgsAbstractDatabaseProviderConnection::TableProperty::addGeometryColumnType
void addGeometryColumnType(const QgsWkbTypes::Type &type, const QgsCoordinateReferenceSystem &crs)
Appends the geometry column type with the given srid to the geometry column types list.
Definition: qgsabstractdatabaseproviderconnection.cpp:257
field
const QgsField & field
Definition: qgsfield.h:456
QgsField::name
QString name
Definition: qgsfield.h:59
QgsAbstractDatabaseProviderConnection::deleteField
virtual void deleteField(const QString &fieldName, const QString &schema, const QString &tableName, bool force=false) const SIP_THROW(QgsProviderConnectionException)
Deletes the field with the specified name.
Definition: qgsabstractdatabaseproviderconnection.cpp:163
QgsWkbTypes::coordDimensions
static int coordDimensions(Type type) SIP_HOLDGIL
Returns the coordinate dimension of the geometry type as an integer.
Definition: qgswkbtypes.h:925
QgsAbstractDatabaseProviderConnection::TableProperty::defaultName
QString defaultName() const
Returns the default name for the table entry.
Definition: qgsabstractdatabaseproviderconnection.cpp:291
QgsAbstractDatabaseProviderConnection::TableProperty
The TableProperty class represents a database table or view.
Definition: qgsabstractdatabaseproviderconnection.h:82
QgsAbstractDatabaseProviderConnection::mGeometryColumnCapabilities
GeometryColumnCapabilities mGeometryColumnCapabilities
Definition: qgsabstractdatabaseproviderconnection.h:585
QgsAbstractDatabaseProviderConnection::fields
virtual QgsFields fields(const QString &schema, const QString &table) const SIP_THROW(QgsProviderConnectionException)
Returns the fields of a table and schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:276
QgsAbstractDatabaseProviderConnection::geometryColumnCapabilities
virtual GeometryColumnCapabilities geometryColumnCapabilities()
Returns connection geomerty column capabilities (Z, M, SinglePart, Curves)
Definition: qgsabstractdatabaseproviderconnection.cpp:39
QgsAbstractDatabaseProviderConnection::TableProperty::setFlag
void setFlag(const TableFlag &flag)
Sets a flag.
Definition: qgsabstractdatabaseproviderconnection.cpp:316
QgsAbstractDatabaseProviderConnection::mProviderKey
QString mProviderKey
Definition: qgsabstractdatabaseproviderconnection.h:586
QgsAbstractDatabaseProviderConnection::tableExists
virtual bool tableExists(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Checks whether a table name exists in the given schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:102
QgsAbstractDatabaseProviderConnection::TableProperty::info
QVariantMap info() const
Returns additional information about the table.
Definition: qgsabstractdatabaseproviderconnection.cpp:360
QgsAbstractDatabaseProviderConnection::renameSchema
virtual void renameSchema(const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException)
Renames a schema with the specified name.
Definition: qgsabstractdatabaseproviderconnection.cpp:131
QgsAbstractDatabaseProviderConnection::TableProperty::setGeometryColumnCount
void setGeometryColumnCount(int geometryColumnCount)
Sets the geometryColumnCount.
Definition: qgsabstractdatabaseproviderconnection.cpp:355
QgsAbstractDatabaseProviderConnection::QgsAbstractDatabaseProviderConnection
QgsAbstractDatabaseProviderConnection(const QString &name)
Creates a new connection with name by reading its configuration from the settings.
Definition: qgsabstractdatabaseproviderconnection.cpp:23
QgsAbstractDatabaseProviderConnection::mCapabilities
Capabilities mCapabilities
Definition: qgsabstractdatabaseproviderconnection.h:584
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsAbstractDatabaseProviderConnection::TableProperty::maxCoordinateDimensions
int maxCoordinateDimensions() const
Returns the maximum coordinate dimensions of the geometries of a vector table.
Definition: qgsabstractdatabaseproviderconnection.cpp:321
QgsAbstractDatabaseProviderConnection::TableProperty::geometryColumnTypes
QList< QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType > geometryColumnTypes() const
Returns the list of geometry column types and CRSs.
Definition: qgsabstractdatabaseproviderconnection.cpp:271
QgsAbstractDatabaseProviderConnection::TableProperty::crsList
QList< QgsCoordinateReferenceSystem > crsList() const
Returns the list of CRSs supported by the geometry column.
Definition: qgsabstractdatabaseproviderconnection.cpp:390
QgsAbstractDatabaseProviderConnection::dropVectorTable
virtual void dropVectorTable(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Drops a vector (or aspatial) table with given schema (schema is ignored if not supported by the backe...
Definition: qgsabstractdatabaseproviderconnection.cpp:97
QgsAbstractDatabaseProviderConnection::providerKey
QString providerKey() const
Returns the provider key.
QgsAbstractDatabaseProviderConnection::executeSql
virtual QList< QList< QVariant > > executeSql(const QString &sql, QgsFeedback *feedback=nullptr) const SIP_THROW(QgsProviderConnectionException)
Executes raw sql and returns the (possibly empty) list of results in a multi-dimensional array,...
Definition: qgsabstractdatabaseproviderconnection.cpp:136
QgsProviderConnectionException
Custom exception class for provider connection related exceptions.
Definition: qgsexception.h:101
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsAbstractDatabaseProviderConnection::vacuum
virtual void vacuum(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Vacuum the database table with given schema and name (schema is ignored if not supported by the backe...
Definition: qgsabstractdatabaseproviderconnection.cpp:142
QgsAbstractDatabaseProviderConnection::deleteSpatialIndex
virtual void deleteSpatialIndex(const QString &schema, const QString &name, const QString &geometryColumn) const SIP_THROW(QgsProviderConnectionException)
Deletes the existing spatial index for the database table with given schema, name and geometryColumn ...
Definition: qgsabstractdatabaseproviderconnection.cpp:152
qgsvectorlayer.h
QgsVectorLayer::LayerOptions
Setting options for loading vector layers.
Definition: qgsvectorlayer.h:425
QgsAbstractDatabaseProviderConnection::SpatialIndexOptions
Contains extra options relating to spatial index creation.
Definition: qgsabstractdatabaseproviderconnection.h:476
QgsAbstractDatabaseProviderConnection::TableProperty::setFlags
void setFlags(const TableFlags &flags)
Sets the table flags.
Definition: qgsabstractdatabaseproviderconnection.cpp:385
QgsAbstractDatabaseProviderConnection::TableProperty::comment
QString comment() const
Returns the table comment.
Definition: qgsabstractdatabaseproviderconnection.cpp:370
QgsAbstractDatabaseProviderConnection::TableProperty::tableName
QString tableName() const
Returns the table name.
Definition: qgsabstractdatabaseproviderconnection.cpp:247
QgsAbstractDatabaseProviderConnection::Capability
Capability
The Capability enum represents the operations supported by the connection.
Definition: qgsabstractdatabaseproviderconnection.h:280
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsAbstractDatabaseProviderConnection::TableProperty::at
TableProperty at(int index) const
Returns the table property corresponding to the geometry type at the given index.
Definition: qgsabstractdatabaseproviderconnection.cpp:298
QgsAbstractDatabaseProviderConnection::TableProperty::setTableName
void setTableName(const QString &name)
Sets the table name to name.
Definition: qgsabstractdatabaseproviderconnection.cpp:252
QgsAbstractDatabaseProviderConnection::TableProperty::setInfo
void setInfo(const QVariantMap &info)
Sets additional information about the table to info.
Definition: qgsabstractdatabaseproviderconnection.cpp:365
QgsAbstractDatabaseProviderConnection::createVectorTable
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 SIP_THROW(QgsProviderConnectionException)
Creates an empty table with name in the given schema (schema is ignored if not supported by the backe...
Definition: qgsabstractdatabaseproviderconnection.cpp:68
QgsAbstractDatabaseProviderConnection::TableProperty::geometryColumnCount
int geometryColumnCount() const
Returns the number of geometry columns in the original table this entry refers to.
Definition: qgsabstractdatabaseproviderconnection.cpp:350
QgsAbstractDatabaseProviderConnection::TableFlag
TableFlag
Flags for table properties.
Definition: qgsabstractdatabaseproviderconnection.h:57
qgsexception.h
QgsAbstractDatabaseProviderConnection::TableProperty::GeometryColumnType
The GeometryColumnType struct represents the combination of geometry type and CRS for the table geome...
Definition: qgsabstractdatabaseproviderconnection.h:97
QgsAbstractDatabaseProviderConnection::table
virtual QgsAbstractDatabaseProviderConnection::TableProperty table(const QString &schema, const QString &table) const SIP_THROW(QgsProviderConnectionException)
Returns information on a table in the given schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:220
QgsAbstractProviderConnection
The QgsAbstractProviderConnection provides an interface for data provider connections.
Definition: qgsabstractproviderconnection.h:45
qgslogger.h
QgsAbstractDatabaseProviderConnection::renameVectorTable
virtual void renameVectorTable(const QString &schema, const QString &name, const QString &newName) const SIP_THROW(QgsProviderConnectionException)
Renames a vector or aspatial table with given schema (schema is ignored if not supported by the backe...
Definition: qgsabstractdatabaseproviderconnection.cpp:87
QgsAbstractDatabaseProviderConnection::TableProperty::flags
TableFlags flags() const
Returns the table flags.
Definition: qgsabstractdatabaseproviderconnection.cpp:380
QgsAbstractDatabaseProviderConnection::TableProperty::setComment
void setComment(const QString &comment)
Sets the table comment.
Definition: qgsabstractdatabaseproviderconnection.cpp:375
qgsabstractdatabaseproviderconnection.h
QgsAbstractDatabaseProviderConnection::TableProperty::setGeometryColumn
void setGeometryColumn(const QString &geometryColumn)
Sets the geometry column name to geometryColumn.
Definition: qgsabstractdatabaseproviderconnection.cpp:415
QgsAbstractDatabaseProviderConnection::dropRasterTable
virtual void dropRasterTable(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Drops a raster table with given schema (schema is ignored if not supported by the backend) and name.
Definition: qgsabstractdatabaseproviderconnection.cpp:116
QgsVectorLayer::LayerOptions::skipCrsValidation
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
Definition: qgsvectorlayer.h:503
QgsAbstractDatabaseProviderConnection::TableProperty::schema
QString schema() const
Returns the schema or an empty string for backends that do not support a schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:420
QgsAbstractDatabaseProviderConnection::schemas
virtual QStringList schemas() const SIP_THROW(QgsProviderConnectionException)
Returns information about the existing schemas.
Definition: qgsabstractdatabaseproviderconnection.cpp:241
QgsAbstractDatabaseProviderConnection::TableProperty::operator==
bool operator==(const QgsAbstractDatabaseProviderConnection::TableProperty &other) const
Definition: qgsabstractdatabaseproviderconnection.cpp:331
QgsAbstractDatabaseProviderConnection::tableUri
virtual QString tableUri(const QString &schema, const QString &name) const SIP_THROW(QgsProviderConnectionException)
Returns the URI string for the given table and schema.
Definition: qgsabstractdatabaseproviderconnection.cpp:44
QgsAbstractDatabaseProviderConnection::capabilities
Capabilities capabilities() const
Returns connection capabilities.
Definition: qgsabstractdatabaseproviderconnection.cpp:34
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50