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
Returns any associated authentication configuration ID stored in the URI.
Clears the schema stored in the URI.
Returns the connection part of the URI.
Returns the database name stored in the URI.
Decodes SSL mode string into enum value.
Set to
True
to disable selection by feature ID.Returns the driver name stored in the URI
Encodes SSL mode enum value into a string.
Returns the complete encoded URI as a byte array.
Returns the name of the geometry column stored in the URI, if set.
Returns
True
if a parameter with the specifiedkey
exists.Returns the host name stored in the URI.
Returns the name of the (primary) key column for the referenced table.
Returns a generic parameter value corresponding to the specified
key
.Returns multiple generic parameter values corresponding to the specified
key
.Returns the password stored in the URI.
Returns the port stored in the URI.
Returns the URI’s table name, escaped and quoted.
Removes a generic parameter by
key
.Removes the password element from a URI.
Returns the schema stored in the URI.
Returns whether the selection by feature ID is disabled.
Returns the service name associated with the URI.
Sets the authentication configuration ID for the URI.
Sets all connection related members at once.
Sets all data source related members at once.
Sets the URI database name.
Sets the
driver
name stored in the URI.Sets the complete encoded
uri
from a string value.Sets the name of the (primary) key
column
.Sets a generic parameter
value
on the URI.Sets a generic parameter list
value
on the URI.Sets the
password
for the URI.Sets the
scheme
for the URI.Sets the SQL query for the URI.
Sets the spatial reference ID associated with the URI.
Sets whether estimated metadata should be used for the connection.
Sets the
username
for the URI.Sets the WKB
type
associated with the URI.Returns the SQL query stored in the URI, if set.
Returns the spatial reference ID associated with the URI.
Returns the SSL mode associated with the URI.
Returns the table name stored in the URI.
Returns the complete URI as a string.
Returns
True
if estimated metadata should be used for the connection.Returns the username stored in the URI.
Returns the WKB type associated with the URI.
Signals
Attributes
-
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 specifiedkey
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.
-
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.
-
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.
-