Class: QgsDataSourceUri

class qgis.core.QgsDataSourceUri

Bases: sip.wrapper

QgsDataSourceUri(uri: str) Constructor for QgsDataSourceUri which parses an input uri string.

QgsDataSourceUri(QgsDataSourceUri)

Class for storing the component parts of a RDBMS data source URI (e.g. a Postgres data source).

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

Enums

Methods

authConfigId

Returns any associated authentication configuration ID stored in the URI.

clearSchema

Clears the schema stored in the URI.

connectionInfo

Returns the connection part of the URI.

database

Returns the database name stored in the URI.

decodeSslMode

Decodes SSL mode string into enum value.

disableSelectAtId

Set to True to disable selection by feature ID.

driver

Returns the driver name stored in the URI

encodeSslMode

Encodes SSL mode enum value into a string.

encodedUri

Returns the complete encoded URI as a byte array.

geometryColumn

Returns the name of the geometry column stored in the URI, if set.

hasParam

Returns True if a parameter with the specified key exists.

host

Returns the host name stored in the URI.

keyColumn

Returns the name of the (primary) key column for the referenced table.

param

Returns a generic parameter value corresponding to the specified key.

params

Returns multiple generic parameter values corresponding to the specified key.

password

Returns the password stored in the URI.

port

Returns the port stored in the URI.

quotedTablename

Returns the URI’s table name, escaped and quoted.

removeParam

Removes a generic parameter by key.

removePassword

Removes the password element from a URI.

schema

Returns the schema stored in the URI.

selectAtIdDisabled

Returns whether the selection by feature ID is disabled.

service

Returns the service name associated with the URI.

setAuthConfigId

Sets the authentication configuration ID for the URI.

setConnection

Sets all connection related members at once.

setDataSource

Sets all data source related members at once.

setDatabase

Sets the URI database name.

setDriver

Sets the driver name stored in the URI.

setEncodedUri

Sets the complete encoded uri from a string value.

setGeometryColumn

Sets geometry column name to geometryColumn

setKeyColumn

Sets the name of the (primary) key column.

setParam

Sets a generic parameter value on the URI.

setParamList

Sets a generic parameter list value on the URI.

setPassword

Sets the password for the URI.

setSchema

Sets the scheme for the URI.

setSql

Sets the SQL query for the URI.

setSrid

Sets the spatial reference ID associated with the URI.

setTable

Sets table to table

setUseEstimatedMetadata

Sets whether estimated metadata should be used for the connection.

setUsername

Sets the username for the URI.

setWkbType

Sets the WKB type associated with the URI.

sql

Returns the SQL query stored in the URI, if set.

srid

Returns the spatial reference ID associated with the URI.

sslMode

Returns the SSL mode associated with the URI.

table

Returns the table name stored in the URI.

uri

Returns the complete URI as a string.

useEstimatedMetadata

Returns True if estimated metadata should be used for the connection.

username

Returns the username stored in the URI.

wkbType

Returns the WKB type associated with the URI.

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

Returns any associated authentication configuration ID stored in the URI.

clearSchema(self)

Clears the schema stored in the URI.

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

Returns the connection part of the URI.

database(self) → str

Returns the database name stored in the URI.

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 feature ID.

driver(self) → str

Returns the driver name stored in the URI

New in version 2.16.

encodeSslMode(sslMode: QgsDataSourceUri.SslMode) → str

Encodes SSL mode enum value into a string.

New in version 3.2.

encodedUri(self) → QByteArray

Returns the complete encoded URI as a byte array.

geometryColumn(self) → str

Returns the name of the geometry column stored in the URI, if set.

hasParam(self, key: str) → bool

Returns True if a parameter with the specified key exists.

host(self) → str

Returns the host name stored in the URI.

keyColumn(self) → str

Returns the name of the (primary) key column for the referenced table.

param(self, key: str) → str

Returns a generic parameter value corresponding to the specified key.

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

Returns multiple generic parameter values corresponding to the specified key.

password(self) → str

Returns the password stored in the URI.

port(self) → str

Returns the port stored in the URI.

quotedTablename(self) → str

Returns the URI’s table name, escaped and quoted.

removeParam(self, key: str) → int

Removes a generic parameter by key.

Note

Calling this method removes all the occurrences of key, and returns the number of parameters removed.

removePassword(aUri: str) → str

Removes the password element from a URI.

schema(self) → str

Returns the schema stored in the URI.

selectAtIdDisabled(self) → bool

Returns whether the selection by feature ID is disabled.

service(self) → str

Returns the service name associated with the URI.

setAuthConfigId(self, authcfg: str)

Sets the authentication configuration ID for the URI.

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 a 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 the URI database name.

setDriver(self, driver: str)

Sets the driver name stored in the URI.

New in version 2.16.

setEncodedUri(self, uri: str)

Sets the complete encoded uri from a string value.

setGeometryColumn(self, geometryColumn: str)

Sets geometry column name to geometryColumn

New in version 3.10.

setKeyColumn(self, column: str)

Sets the name of the (primary) key column.

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

Sets a generic parameter value on the URI.

Note

If a parameter with the specified key already exists, another is inserted and the existing value is left unchanged.

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

Sets a generic parameter list value on the URI.

Note

available in Python as setParamList

setPassword(self, password: str)

Sets the password for the URI.

setSchema(self, schema: str)

Sets the scheme for the URI.

New in version 2.12.

setSql(self, sql: str)

Sets the SQL query for the URI.

setSrid(self, srid: str)

Sets the spatial reference ID associated with the URI.

setTable(self, table: str)

Sets table to table

New in version 3.10.

setUseEstimatedMetadata(self, flag: bool)

Sets whether estimated metadata should be used for the connection.

setUsername(self, username: str)

Sets the username for the URI.

setWkbType(self, type: QgsWkbTypes.Type)

Sets the WKB type associated with the URI.

sql(self) → str

Returns the SQL query stored in the URI, if set.

srid(self) → str

Returns the spatial reference ID associated with the URI.

sslMode(self) → QgsDataSourceUri.SslMode

Returns the SSL mode associated with the URI.

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

Returns the table name stored in the URI.

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

Returns the complete URI as a string.

useEstimatedMetadata(self) → bool

Returns True if estimated metadata should be used for the connection.

username(self) → str

Returns the username stored in the URI.

wkbType(self) → QgsWkbTypes.Type

Returns the WKB type associated with the URI.