Class: QgsDataSourceUri

class qgis.core.QgsDataSourceUri

Bases: sip.wrapper

default constructor

QgsDataSourceUri(uri: str) constructor which parses input URI

QgsDataSourceUri(QgsDataSourceUri)

Enums

Methods

authConfigId

Any associated authentication configuration ID

clearSchema

Clears the schema

connectionInfo

Returns connection part of URI

database

Returns the database

decodeSslMode

Decodes SSL mode string into enum value.

disableSelectAtId

Sets to true to disable selection by id

driver

encodeSslMode

Encodes SSL mode enum value into a string.

encodedUri

Returns complete encoded uri (generic mode)

geometryColumn

Returns the name of the geometry column

hasParam

Test if param exists (generic mode)

host

Returns the host

keyColumn

Returns the name of the (primary) key column

param

Gets generic param (generic mode)

params

Gets multiple generic param (generic mode)

password

Returns the password

port

Returns the port

quotedTablename

quoted table name

removeParam

Remove generic param (generic mode)

removePassword

Removes password element from uris

schema

Returns the schema

selectAtIdDisabled

Returns whether the selection by id is disabled

service

Returns the service name

setAuthConfigId

Sets authentication configuration ID

setConnection

Sets all connection related members at once

setDataSource

Sets all data source related members at once

setDatabase

Sets database

setDriver

setEncodedUri

Sets complete encoded uri (generic mode)

setKeyColumn

Sets the name of the (primary) key column

setParam

Set generic param (generic mode)

setParamList

setPassword

Sets password

setSchema

setSql

Sets the SQL query

setSrid

Sets the srid

setUseEstimatedMetadata

Sets use Estimated Metadata

setUsername

Sets username

setWkbType

Sets the wkb type

sql

Returns the SQL query

srid

Returns the srid

sslMode

Returns the SSL mode

table

Returns the table

uri

Returns complete uri

useEstimatedMetadata

Returns true if estimated metadata are used

username

Returns the username

wkbType

The wkb type.

Signals

Attributes

SslAllow

SslDisable

SslPrefer

SslRequire

SslVerifyCa

SslVerifyFull

staticMetaObject

SslAllow = 2
SslDisable = 1
class SslMode

Bases: int

baseClass

alias of QgsDataSourceUri

SslPrefer = 0
SslRequire = 3
SslVerifyCa = 4
SslVerifyFull = 5
authConfigId(self) → str

Any associated authentication configuration ID

clearSchema(self)

Clears the schema

connectionInfo(self, expandAuthConfig: bool = True) → str

Returns connection part of URI

database(self) → str

Returns the database

decodeSslMode(sslMode: str) → QgsDataSourceUri.SslMode

Decodes SSL mode string into enum value. If the string is not recognized, SslPrefer is returned.

New in version 3.2.

disableSelectAtId(self, flag: bool)

Sets to true to disable selection by id

driver(self) → str
encodeSslMode(sslMode: QgsDataSourceUri.SslMode) → str

Encodes SSL mode enum value into a string.

New in version 3.2.

encodedUri(self) → QByteArray

Returns complete encoded uri (generic mode)

geometryColumn(self) → str

Returns the name of the geometry column

hasParam(self, key: str) → bool

Test if param exists (generic mode)

host(self) → str

Returns the host

keyColumn(self) → str

Returns the name of the (primary) key column

param(self, key: str) → str

Gets generic param (generic mode)

params(self, key: str) → List[str]

Gets multiple generic param (generic mode)

password(self) → str

Returns the password

port(self) → str

Returns the port

quotedTablename(self) → str

quoted table name

removeParam(self, key: str) → int

Remove generic param (generic mode)

Note

remove all occurrences of key, returns number of params removed

removePassword(aUri: str) → str

Removes password element from uris

schema(self) → str

Returns the schema

selectAtIdDisabled(self) → bool

Returns whether the selection by id is disabled

service(self) → str

Returns the service name

setAuthConfigId(self, authcfg: str)

Sets authentication configuration ID

setConnection(self, aHost: str, aPort: str, aDatabase: str, aUsername: str, aPassword: str, sslmode: QgsDataSourceUri.SslMode = QgsDataSourceUri.SslPrefer, authConfigId: str = '')

Sets all connection related members at once

setConnection(self, aService: str, aDatabase: str, aUsername: str, aPassword: str, sslmode: QgsDataSourceUri.SslMode = QgsDataSourceUri.SslPrefer, authConfigId: str = ‘’) Sets all connection related members at once (for the service case)

setDataSource(self, aSchema: str, aTable: str, aGeometryColumn: str, aSql: str = '', aKeyColumn: str = '')

Sets all data source related members at once

setDatabase(self, database: str)

Sets database

setDriver(self, driver: str)
setEncodedUri(self, uri: str)

Sets complete encoded uri (generic mode)

setKeyColumn(self, column: str)

Sets the name of the (primary) key column

setParam(self, key: str, value: str)

Set generic param (generic mode)

Note

if key exists, another is inserted

setParamList(self, key: str, value: Iterable[str])

Note

available in Python as setParamList

setPassword(self, password: str)

Sets password

setSchema(self, schema: str)
setSql(self, sql: str)

Sets the SQL query

setSrid(self, srid: str)

Sets the srid

setUseEstimatedMetadata(self, flag: bool)

Sets use Estimated Metadata

setUsername(self, username: str)

Sets username

setWkbType(self, type: QgsWkbTypes.Type)

Sets the wkb type

sql(self) → str

Returns the SQL query

srid(self) → str

Returns the srid

sslMode(self) → QgsDataSourceUri.SslMode

Returns the SSL mode

staticMetaObject = <PyQt5.QtCore.QMetaObject object>
table(self) → str

Returns the table

uri(self, expandAuthConfig: bool = True) → str

Returns complete uri

useEstimatedMetadata(self) → bool

Returns true if estimated metadata are used

username(self) → str

Returns the username

wkbType(self) → QgsWkbTypes.Type

The wkb type.