QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsDataSourceURI Class Reference

Class for storing the component parts of a PostgreSQL/RDBMS datasource URI. More...

#include <qgsdatasourceuri.h>

Public Types

enum  SSLmode {
  SSLprefer, SSLdisable, SSLallow, SSLrequire,
  SSLverifyCA, SSLverifyFull
}
 

Public Member Functions

 QgsDataSourceURI ()
 default constructor More...
 
 QgsDataSourceURI (QString uri)
 constructor which parses input URI More...
 
 QgsDataSourceURI (const QByteArray &uri)
 constructor which parses input encoded URI (generic mode) More...
 
QString authConfigId () const
 Any associated authentication configuration ID. More...
 
void clearSchema ()
 Clears the schema. More...
 
QString connectionInfo (bool expandAuthConfig=true) const
 return connection part of URI More...
 
QString database () const
 Returns the database. More...
 
void disableSelectAtId (bool theFlag)
 Set to true to disable selection by id. More...
 
QString driver () const
 Returns the driver. More...
 
QByteArray encodedUri () const
 return complete encoded uri (generic mode) More...
 
QString geometryColumn () const
 Return the name of the geometry column. More...
 
bool hasParam (const QString &key) const
 Test if param exists (generic mode) More...
 
QString host () const
 Returns the host. More...
 
QString keyColumn () const
 Returns the name of the (primary) key column. More...
 
QgsWKBTypes::Type newWkbType () const
 The wkb type. More...
 
QString param (const QString &key) const
 Get generic param (generic mode) More...
 
QStringList params (const QString &key) const
 Get multiple generic param (generic mode) More...
 
QString password () const
 Returns the password. More...
 
QString port () const
 Returns the port. More...
 
QString quotedTablename () const
 quoted table name More...
 
int removeParam (const QString &key)
 Remove generic param (generic mode) More...
 
QString schema () const
 Returns the schema. More...
 
bool selectAtIdDisabled () const
 Returns whether the selection by id is disabled. More...
 
QString service () const
 Returns the service name. More...
 
void setAuthConfigId (const QString &authcfg)
 Set authentication configuration ID. More...
 
void setConnection (const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SSLmode sslmode=SSLprefer, const QString &authConfigId=QString())
 Set all connection related members at once. More...
 
void setConnection (const QString &aService, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SSLmode sslmode=SSLprefer, const QString &authConfigId=QString())
 Set all connection related members at once (for the service case) More...
 
void setDatabase (const QString &database)
 Set database. More...
 
void setDataSource (const QString &aSchema, const QString &aTable, const QString &aGeometryColumn, const QString &aSql=QString(), const QString &aKeyColumn=QString())
 Set all data source related members at once. More...
 
void setDriver (const QString &driver)
 Sets the driver name. More...
 
void setEncodedUri (const QByteArray &uri)
 set complete encoded uri (generic mode) More...
 
void setEncodedUri (const QString &uri)
 set complete encoded uri (generic mode) More...
 
void setKeyColumn (const QString &column)
 Sets the name of the (primary) key column. More...
 
void setParam (const QString &key, const QString &value)
 Set generic param (generic mode) More...
 
void setParam (const QString &key, const QStringList &value)
 
void setPassword (const QString &password)
 set password More...
 
void setSchema (const QString &schema)
 set the table schema More...
 
void setSql (const QString &sql)
 Sets the SQL query. More...
 
void setSrid (const QString &srid)
 Sets the srid. More...
 
void setUseEstimatedMetadata (bool theFlag)
 set use Estimated Metadata More...
 
void setUsername (const QString &username)
 set username More...
 
Q_DECL_DEPRECATED void setWkbType (QGis::WkbType type)
 
void setWkbType (QgsWKBTypes::Type type)
 Sets the wkb type. More...
 
QString sql () const
 Returns the SQL query. More...
 
QString srid () const
 Returns the srid. More...
 
enum SSLmode sslMode () const
 Returns the SSL mode. More...
 
QString table () const
 Returns the table. More...
 
QString uri (bool expandAuthConfig=true) const
 return complete uri More...
 
bool useEstimatedMetadata () const
 Returns true if estimated metadata are used. More...
 
QString username () const
 Returns the username. More...
 
Q_DECL_DEPRECATED QGis::WkbType wkbType () const
 The (old) wkb type. More...
 

Static Public Member Functions

static QString removePassword (const QString &aUri)
 Removes password element from uris. More...
 

Detailed Description

Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.

This structure stores the database connection information, including host, database, user name, password, schema, password, and sql where clause

Extended to support generic params so that it may be used by any provider. The 2 modes (the old - RDMS specific and the new generic) may not yet be mixed. (Radim Blazek 4/2012)

Definition at line 35 of file qgsdatasourceuri.h.

Member Enumeration Documentation

◆ SSLmode

Enumerator
SSLprefer 
SSLdisable 
SSLallow 
SSLrequire 
SSLverifyCA 
SSLverifyFull 

Definition at line 38 of file qgsdatasourceuri.h.

Constructor & Destructor Documentation

◆ QgsDataSourceURI() [1/3]

QgsDataSourceURI::QgsDataSourceURI ( )

default constructor

Definition at line 28 of file qgsdatasourceuri.cpp.

◆ QgsDataSourceURI() [2/3]

QgsDataSourceURI::QgsDataSourceURI ( QString  uri)

constructor which parses input URI

Definition at line 38 of file qgsdatasourceuri.cpp.

◆ QgsDataSourceURI() [3/3]

QgsDataSourceURI::QgsDataSourceURI ( const QByteArray uri)

constructor which parses input encoded URI (generic mode)

Member Function Documentation

◆ authConfigId()

QString QgsDataSourceURI::authConfigId ( ) const

Any associated authentication configuration ID.

Definition at line 269 of file qgsdatasourceuri.cpp.

◆ clearSchema()

void QgsDataSourceURI::clearSchema ( )

Clears the schema.

Definition at line 387 of file qgsdatasourceuri.cpp.

◆ connectionInfo()

QString QgsDataSourceURI::connectionInfo ( bool  expandAuthConfig = true) const

return connection part of URI

Definition at line 481 of file qgsdatasourceuri.cpp.

◆ database()

QString QgsDataSourceURI::database ( ) const

Returns the database.

Definition at line 294 of file qgsdatasourceuri.cpp.

◆ disableSelectAtId()

void QgsDataSourceURI::disableSelectAtId ( bool  theFlag)

Set to true to disable selection by id.

Definition at line 372 of file qgsdatasourceuri.cpp.

◆ driver()

QString QgsDataSourceURI::driver ( ) const

Returns the driver.

Definition at line 314 of file qgsdatasourceuri.cpp.

◆ encodedUri()

QByteArray QgsDataSourceURI::encodedUri ( ) const

return complete encoded uri (generic mode)

Definition at line 606 of file qgsdatasourceuri.cpp.

◆ geometryColumn()

QString QgsDataSourceURI::geometryColumn ( ) const

Return the name of the geometry column.

Definition at line 339 of file qgsdatasourceuri.cpp.

◆ hasParam()

bool QgsDataSourceURI::hasParam ( const QString key) const

Test if param exists (generic mode)

Definition at line 761 of file qgsdatasourceuri.cpp.

◆ host()

QString QgsDataSourceURI::host ( ) const

Returns the host.

Definition at line 289 of file qgsdatasourceuri.cpp.

◆ keyColumn()

QString QgsDataSourceURI::keyColumn ( ) const

Returns the name of the (primary) key column.

Definition at line 344 of file qgsdatasourceuri.cpp.

◆ newWkbType()

QgsWKBTypes::Type QgsDataSourceURI::newWkbType ( ) const

The wkb type.

Note
Will be removed in 3.0

Definition at line 707 of file qgsdatasourceuri.cpp.

◆ param()

QString QgsDataSourceURI::param ( const QString key) const

Get generic param (generic mode)

Definition at line 751 of file qgsdatasourceuri.cpp.

◆ params()

QStringList QgsDataSourceURI::params ( const QString key) const

Get multiple generic param (generic mode)

Definition at line 756 of file qgsdatasourceuri.cpp.

◆ password()

QString QgsDataSourceURI::password ( ) const

Returns the password.

Definition at line 299 of file qgsdatasourceuri.cpp.

◆ port()

QString QgsDataSourceURI::port ( ) const

Returns the port.

Definition at line 309 of file qgsdatasourceuri.cpp.

◆ quotedTablename()

QString QgsDataSourceURI::quotedTablename ( ) const

quoted table name

Definition at line 636 of file qgsdatasourceuri.cpp.

◆ removeParam()

int QgsDataSourceURI::removeParam ( const QString key)

Remove generic param (generic mode)

Definition at line 746 of file qgsdatasourceuri.cpp.

◆ removePassword()

QString QgsDataSourceURI::removePassword ( const QString aUri)
static

Removes password element from uris.

Definition at line 235 of file qgsdatasourceuri.cpp.

◆ schema()

QString QgsDataSourceURI::schema ( ) const

Returns the schema.

Definition at line 324 of file qgsdatasourceuri.cpp.

◆ selectAtIdDisabled()

bool QgsDataSourceURI::selectAtIdDisabled ( ) const

Returns whether the selection by id is disabled.

Definition at line 377 of file qgsdatasourceuri.cpp.

◆ service()

QString QgsDataSourceURI::service ( ) const

Returns the service name.

Definition at line 284 of file qgsdatasourceuri.cpp.

◆ setAuthConfigId()

void QgsDataSourceURI::setAuthConfigId ( const QString authcfg)

Set authentication configuration ID.

Definition at line 692 of file qgsdatasourceuri.cpp.

◆ setConnection() [1/2]

void QgsDataSourceURI::setConnection ( const QString aHost,
const QString aPort,
const QString aDatabase,
const QString aUsername,
const QString aPassword,
SSLmode  sslmode = SSLprefer,
const QString authConfigId = QString() 
)

Set all connection related members at once.

Definition at line 647 of file qgsdatasourceuri.cpp.

◆ setConnection() [2/2]

void QgsDataSourceURI::setConnection ( const QString aService,
const QString aDatabase,
const QString aUsername,
const QString aPassword,
SSLmode  sslmode = SSLprefer,
const QString authConfigId = QString() 
)

Set all connection related members at once (for the service case)

Definition at line 664 of file qgsdatasourceuri.cpp.

◆ setDatabase()

void QgsDataSourceURI::setDatabase ( const QString database)

Set database.

Definition at line 697 of file qgsdatasourceuri.cpp.

◆ setDataSource()

void QgsDataSourceURI::setDataSource ( const QString aSchema,
const QString aTable,
const QString aGeometryColumn,
const QString aSql = QString(),
const QString aKeyColumn = QString() 
)

Set all data source related members at once.

Definition at line 679 of file qgsdatasourceuri.cpp.

◆ setDriver()

void QgsDataSourceURI::setDriver ( const QString driver)

Sets the driver name.

Definition at line 350 of file qgsdatasourceuri.cpp.

◆ setEncodedUri() [1/2]

void QgsDataSourceURI::setEncodedUri ( const QByteArray uri)

set complete encoded uri (generic mode)

Definition at line 619 of file qgsdatasourceuri.cpp.

◆ setEncodedUri() [2/2]

void QgsDataSourceURI::setEncodedUri ( const QString uri)

set complete encoded uri (generic mode)

Definition at line 631 of file qgsdatasourceuri.cpp.

◆ setKeyColumn()

void QgsDataSourceURI::setKeyColumn ( const QString column)

Sets the name of the (primary) key column.

Definition at line 356 of file qgsdatasourceuri.cpp.

◆ setParam() [1/2]

void QgsDataSourceURI::setParam ( const QString key,
const QString value 
)

Set generic param (generic mode)

Definition at line 732 of file qgsdatasourceuri.cpp.

◆ setParam() [2/2]

void QgsDataSourceURI::setParam ( const QString key,
const QStringList value 
)
Note
available in python as setParamList

Definition at line 738 of file qgsdatasourceuri.cpp.

◆ setPassword()

void QgsDataSourceURI::setPassword ( const QString password)

set password

Definition at line 304 of file qgsdatasourceuri.cpp.

◆ setSchema()

void QgsDataSourceURI::setSchema ( const QString schema)

set the table schema

Definition at line 392 of file qgsdatasourceuri.cpp.

◆ setSql()

void QgsDataSourceURI::setSql ( const QString sql)

Sets the SQL query.

Definition at line 382 of file qgsdatasourceuri.cpp.

◆ setSrid()

void QgsDataSourceURI::setSrid ( const QString srid)

Sets the srid.

Definition at line 727 of file qgsdatasourceuri.cpp.

◆ setUseEstimatedMetadata()

void QgsDataSourceURI::setUseEstimatedMetadata ( bool  theFlag)

set use Estimated Metadata

Definition at line 362 of file qgsdatasourceuri.cpp.

◆ setUsername()

void QgsDataSourceURI::setUsername ( const QString username)

set username

Definition at line 279 of file qgsdatasourceuri.cpp.

◆ setWkbType() [1/2]

void QgsDataSourceURI::setWkbType ( QGis::WkbType  type)

◆ setWkbType() [2/2]

void QgsDataSourceURI::setWkbType ( QgsWKBTypes::Type  type)

Sets the wkb type.

Definition at line 717 of file qgsdatasourceuri.cpp.

◆ sql()

QString QgsDataSourceURI::sql ( ) const

Returns the SQL query.

Definition at line 334 of file qgsdatasourceuri.cpp.

◆ srid()

QString QgsDataSourceURI::srid ( ) const

Returns the srid.

Definition at line 722 of file qgsdatasourceuri.cpp.

◆ sslMode()

QgsDataSourceURI::SSLmode QgsDataSourceURI::sslMode ( ) const

Returns the SSL mode.

Definition at line 319 of file qgsdatasourceuri.cpp.

◆ table()

QString QgsDataSourceURI::table ( ) const

Returns the table.

Definition at line 329 of file qgsdatasourceuri.cpp.

◆ uri()

QString QgsDataSourceURI::uri ( bool  expandAuthConfig = true) const

return complete uri

Definition at line 553 of file qgsdatasourceuri.cpp.

◆ useEstimatedMetadata()

bool QgsDataSourceURI::useEstimatedMetadata ( ) const

Returns true if estimated metadata are used.

Definition at line 367 of file qgsdatasourceuri.cpp.

◆ username()

QString QgsDataSourceURI::username ( ) const

Returns the username.

Definition at line 274 of file qgsdatasourceuri.cpp.

◆ wkbType()

QGis::WkbType QgsDataSourceURI::wkbType ( ) const

The (old) wkb type.

Deprecated:
Will return QgsWKBTypes::Type in 3.0. Prefer newWkbType() in the meantime

Definition at line 702 of file qgsdatasourceuri.cpp.


The documentation for this class was generated from the following files: