Subgroup: Data

Class: QgsDataSourceUri

class qgis.core.QgsDataSourceUri

Bases: sip.wrapper

default constructor

QgsDataSourceUri(uri: str) constructor which parses input URI

QgsDataSourceUri(QgsDataSourceUri)

Methods

authConfigId Any associated authentication configuration ID
clearSchema Clears the schema
connectionInfo return connection part of URI
database Returns the database
decodeSslMode Decodes SSL mode string into enum value.
disableSelectAtId Set to true to disable selection by id
driver
encodeSslMode Encodes SSL mode enum value into a string.
encodedUri return complete encoded uri (generic mode)
geometryColumn Return 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 Get generic param (generic mode)
params Get 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 Set authentication configuration ID
setConnection Set all connection related members at once
setDataSource Set all data source related members at once
setDatabase Set database
setDriver
setEncodedUri set complete encoded uri (generic mode)
setKeyColumn Sets the name of the (primary) key column
setParam Set generic param (generic mode)
setParamList .
setPassword set password
setSchema
setSql Sets the SQL query
setSrid Sets the srid
setUseEstimatedMetadata set use Estimated Metadata
setUsername set 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 return 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
SslAllow = 2
SslDisable = 1
class SslMode

Bases: int

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

return 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)

Set 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

return complete encoded uri (generic mode)

geometryColumn(self) → str

Return 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

Get generic param (generic mode)

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

Get 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)

Set authentication configuration ID

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

Set all connection related members at once

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

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

Set all data source related members at once

setDatabase(self, database: str)

Set database

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

set 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)

set password

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

Sets the SQL query

setSrid(self, srid: str)

Sets the srid

setUseEstimatedMetadata(self, flag: bool)

set use Estimated Metadata

setUsername(self, username: str)

set 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

table(self) → str

Returns the table

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

return 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.