QGIS API Documentation  3.0.2-Girona (307d082)
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 flag)
 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...
 
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 flag)
 set use Estimated Metadata More...
 
void setUsername (const QString &username)
 set username More...
 
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...
 
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...
 
QgsWkbTypes::Type wkbType () const
 The 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.

Definition at line 37 of file qgsdatasourceuri.h.

Member Enumeration Documentation

◆ SslMode

Enumerator
SslPrefer 
SslDisable 
SslAllow 
SslRequire 
SslVerifyCa 
SslVerifyFull 

Definition at line 41 of file qgsdatasourceuri.h.

Constructor & Destructor Documentation

◆ QgsDataSourceUri() [1/3]

QgsDataSourceUri::QgsDataSourceUri ( )

default constructor

Definition at line 29 of file qgsdatasourceuri.cpp.

◆ QgsDataSourceUri() [2/3]

QgsDataSourceUri::QgsDataSourceUri ( QString  uri)

constructor which parses input URI

Definition at line 34 of file qgsdatasourceuri.cpp.

◆ QgsDataSourceUri() [3/3]

QgsDataSourceUri::QgsDataSourceUri ( const QByteArray &  uri)

constructor which parses input encoded URI (generic mode)

Note
not available in Python bindings

Member Function Documentation

◆ authConfigId()

QString QgsDataSourceUri::authConfigId ( ) const

Any associated authentication configuration ID.

Definition at line 260 of file qgsdatasourceuri.cpp.

◆ clearSchema()

void QgsDataSourceUri::clearSchema ( )

Clears the schema.

Definition at line 378 of file qgsdatasourceuri.cpp.

◆ connectionInfo()

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

return connection part of URI

Definition at line 472 of file qgsdatasourceuri.cpp.

◆ database()

QString QgsDataSourceUri::database ( ) const

Returns the database.

Definition at line 285 of file qgsdatasourceuri.cpp.

◆ disableSelectAtId()

void QgsDataSourceUri::disableSelectAtId ( bool  flag)

Set to true to disable selection by id.

Definition at line 363 of file qgsdatasourceuri.cpp.

◆ driver()

QString QgsDataSourceUri::driver ( ) const

Returns the driver.

Definition at line 305 of file qgsdatasourceuri.cpp.

◆ encodedUri()

QByteArray QgsDataSourceUri::encodedUri ( ) const

return complete encoded uri (generic mode)

Definition at line 597 of file qgsdatasourceuri.cpp.

◆ geometryColumn()

QString QgsDataSourceUri::geometryColumn ( ) const

Return the name of the geometry column.

Definition at line 330 of file qgsdatasourceuri.cpp.

◆ hasParam()

bool QgsDataSourceUri::hasParam ( const QString &  key) const

Test if param exists (generic mode)

Definition at line 739 of file qgsdatasourceuri.cpp.

◆ host()

QString QgsDataSourceUri::host ( ) const

Returns the host.

Definition at line 280 of file qgsdatasourceuri.cpp.

◆ keyColumn()

QString QgsDataSourceUri::keyColumn ( ) const

Returns the name of the (primary) key column.

Definition at line 335 of file qgsdatasourceuri.cpp.

◆ param()

QString QgsDataSourceUri::param ( const QString &  key) const

Get generic param (generic mode)

Definition at line 729 of file qgsdatasourceuri.cpp.

◆ params()

QStringList QgsDataSourceUri::params ( const QString &  key) const

Get multiple generic param (generic mode)

Definition at line 734 of file qgsdatasourceuri.cpp.

◆ password()

QString QgsDataSourceUri::password ( ) const

Returns the password.

Definition at line 290 of file qgsdatasourceuri.cpp.

◆ port()

QString QgsDataSourceUri::port ( ) const

Returns the port.

Definition at line 300 of file qgsdatasourceuri.cpp.

◆ quotedTablename()

QString QgsDataSourceUri::quotedTablename ( ) const

quoted table name

Definition at line 624 of file qgsdatasourceuri.cpp.

◆ removeParam()

int QgsDataSourceUri::removeParam ( const QString &  key)

Remove generic param (generic mode)

Note
remove all occurrences of key, returns number of params removed

Definition at line 724 of file qgsdatasourceuri.cpp.

◆ removePassword()

QString QgsDataSourceUri::removePassword ( const QString &  aUri)
static

Removes password element from uris.

Definition at line 226 of file qgsdatasourceuri.cpp.

◆ schema()

QString QgsDataSourceUri::schema ( ) const

Returns the schema.

Definition at line 315 of file qgsdatasourceuri.cpp.

◆ selectAtIdDisabled()

bool QgsDataSourceUri::selectAtIdDisabled ( ) const

Returns whether the selection by id is disabled.

Definition at line 368 of file qgsdatasourceuri.cpp.

◆ service()

QString QgsDataSourceUri::service ( ) const

Returns the service name.

Definition at line 275 of file qgsdatasourceuri.cpp.

◆ setAuthConfigId()

void QgsDataSourceUri::setAuthConfigId ( const QString &  authcfg)

Set authentication configuration ID.

Definition at line 680 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 635 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 652 of file qgsdatasourceuri.cpp.

◆ setDatabase()

void QgsDataSourceUri::setDatabase ( const QString &  database)

Set database.

Definition at line 685 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 667 of file qgsdatasourceuri.cpp.

◆ setDriver()

void QgsDataSourceUri::setDriver ( const QString &  driver)

Sets the driver name.

Definition at line 341 of file qgsdatasourceuri.cpp.

◆ setEncodedUri() [1/2]

void QgsDataSourceUri::setEncodedUri ( const QByteArray &  uri)

set complete encoded uri (generic mode)

Note
not available in Python bindings

Definition at line 607 of file qgsdatasourceuri.cpp.

◆ setEncodedUri() [2/2]

void QgsDataSourceUri::setEncodedUri ( const QString &  uri)

set complete encoded uri (generic mode)

Definition at line 619 of file qgsdatasourceuri.cpp.

◆ setKeyColumn()

void QgsDataSourceUri::setKeyColumn ( const QString &  column)

Sets the name of the (primary) key column.

Definition at line 347 of file qgsdatasourceuri.cpp.

◆ setParam() [1/2]

void QgsDataSourceUri::setParam ( const QString &  key,
const QString &  value 
)

Set generic param (generic mode)

Note
if key exists, another is inserted

Definition at line 710 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 716 of file qgsdatasourceuri.cpp.

◆ setPassword()

void QgsDataSourceUri::setPassword ( const QString &  password)

set password

Definition at line 295 of file qgsdatasourceuri.cpp.

◆ setSchema()

void QgsDataSourceUri::setSchema ( const QString &  schema)

set the table schema

Definition at line 383 of file qgsdatasourceuri.cpp.

◆ setSql()

void QgsDataSourceUri::setSql ( const QString &  sql)

Sets the SQL query.

Definition at line 373 of file qgsdatasourceuri.cpp.

◆ setSrid()

void QgsDataSourceUri::setSrid ( const QString &  srid)

Sets the srid.

Definition at line 705 of file qgsdatasourceuri.cpp.

◆ setUseEstimatedMetadata()

void QgsDataSourceUri::setUseEstimatedMetadata ( bool  flag)

set use Estimated Metadata

Definition at line 353 of file qgsdatasourceuri.cpp.

◆ setUsername()

void QgsDataSourceUri::setUsername ( const QString &  username)

set username

Definition at line 270 of file qgsdatasourceuri.cpp.

◆ setWkbType()

void QgsDataSourceUri::setWkbType ( QgsWkbTypes::Type  type)

Sets the wkb type.

Definition at line 695 of file qgsdatasourceuri.cpp.

◆ sql()

QString QgsDataSourceUri::sql ( ) const

Returns the SQL query.

Definition at line 325 of file qgsdatasourceuri.cpp.

◆ srid()

QString QgsDataSourceUri::srid ( ) const

Returns the srid.

Definition at line 700 of file qgsdatasourceuri.cpp.

◆ sslMode()

QgsDataSourceUri::SslMode QgsDataSourceUri::sslMode ( ) const

Returns the SSL mode.

Definition at line 310 of file qgsdatasourceuri.cpp.

◆ table()

QString QgsDataSourceUri::table ( ) const

Returns the table.

Definition at line 320 of file qgsdatasourceuri.cpp.

◆ uri()

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

return complete uri

Definition at line 544 of file qgsdatasourceuri.cpp.

◆ useEstimatedMetadata()

bool QgsDataSourceUri::useEstimatedMetadata ( ) const

Returns true if estimated metadata are used.

Definition at line 358 of file qgsdatasourceuri.cpp.

◆ username()

QString QgsDataSourceUri::username ( ) const

Returns the username.

Definition at line 265 of file qgsdatasourceuri.cpp.

◆ wkbType()

QgsWkbTypes::Type QgsDataSourceUri::wkbType ( ) const

The wkb type.

Definition at line 690 of file qgsdatasourceuri.cpp.


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