Class: QgsAuthConfigurationStorageDb¶
QSqlDatabase based implementation of
QgsAuthConfigurationStorage
.
Added in version 3.40.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: QgsAuthConfigurationStorage.SIP_THROW()
Class Hierarchy¶
Base classes¶
Abstract class that defines the interface for all authentication configuration storage implementations. |
|
Methods
Returns the database connection used by this storage. |
|
Opens the connction to the database. |
|
Runs the specified query on the database. |
|
Executes the specified query on the database using a transaction. |
|
Creates the certificate tables in the database. |
|
Creates the configuration tables in the database. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsAuthConfigurationStorageDb. See the FAQ for more details.
Returns the name of the table used to store the auth settings. |
|
Returns the name of the table used to store the certificate authorities. |
|
Returns the name of the table used to store the certificate identities. |
|
Returns the name of the table used to store the certificate trust policies. |
|
Checks the capabilities of the storage. |
|
Returns the name of the table used to store the master passwords. |
|
Returns the name of the table used to store the method configurations. |
|
Returns the quoted identifier, prefixed with the schema (if not null), ready for the insertion into a SQL query. |
|
Returns the name of the table used to store the SSL custom configurations. |
|
Returns |
- class qgis.core.QgsAuthConfigurationStorageDb[source]¶
Bases:
QgsAuthConfigurationStorage
- __init__(settings: Dict[str | None, Any])
Creates a new QgsAuthConfigurationStorageDb instance from the specified
settings
. Settings can contain the following keys:Mandatory settings:
driver: the database driver to use (default is “QSQLITE”, see: https://doc.qt.io/qt-6/sql-driver.html)
database: the database name (or path in case of QSQLITE)
Optional settings:
host: the database host
user: the database user
password: the database password
port: the database port
schema: the database schema for all the tables (ignored if not supported)
options: the database connection options (see: https://doc.qt.io/qt-6/qsqldatabase.html#setConnectOptions)
Note
Even if this generic storage also works with a pre-existing SQLite DB, a convenience subclass
QgsAuthConfigurationStorageSqlite
is provided for SQLite DBs.- Parameters:
settings (Dict[Optional[str], Any])
- __init__(uri: str | None)
Creates a new QgsAuthConfigurationStorageDb instance from the specified
uri
. The URI should be in the format: verbatim<DRIVER>://<USER>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>[?OPTIONS]endverbatimNote
It is not possible to set the schema in the URI, pass SCHEMA=verbatim<SCHEMA>endverbatim in the options instead.
- Parameters:
uri (Optional[str])
- authDatabaseConnection(self) QSqlDatabase [source]¶
Returns the database connection used by this storage.
- Return type:
QSqlDatabase
- authDbOpen(self) bool [source]¶
Opens the connction to the database.
- Return type:
bool
- Returns:
True
if the connection was opened successfully,False
otherwise.
- authDbQuery(self, query: QSqlQuery | None, sql: str | None = '') bool [source]¶
Runs the specified
query
on the database. Optionalsql
can be provided.- Return type:
bool
- Returns:
True
if the query was executed successfully,False
otherwise.- Parameters:
query (Optional[QSqlQuery])
sql (Optional[str] = '')
- authDbTransactionQuery(self, query: QSqlQuery | None) bool [source]¶
Executes the specified
query
on the database using a transaction. Optionalsql
can be provided.- Return type:
bool
- Returns:
True
if the query was executed successfully,False
otherwise.- Parameters:
query (Optional[QSqlQuery])
- virtual authSettingsTableName(self) str [source]¶
Returns the name of the table used to store the auth settings.
- Return type:
str
- virtual certAuthorityTableName(self) str [source]¶
Returns the name of the table used to store the certificate authorities.
- Return type:
str
- virtual certIdentityTableName(self) str [source]¶
Returns the name of the table used to store the certificate identities.
- Return type:
str
- virtual certTrustPolicyTableName(self) str [source]¶
Returns the name of the table used to store the certificate trust policies.
- Return type:
str
- createCertTables(self) bool [source]¶
Creates the certificate tables in the database.
- Return type:
bool
- Returns:
True
if the tables were created successfully,False
otherwise.
- createConfigTables(self) bool [source]¶
Creates the configuration tables in the database.
- Return type:
bool
- Returns:
True
if the tables were created successfully,False
otherwise.
- virtual masterPasswordTableName(self) str [source]¶
Returns the name of the table used to store the master passwords.
- Return type:
str
- virtual methodConfigTableName(self) str [source]¶
Returns the name of the table used to store the method configurations.
- Return type:
str
- virtual quotedQualifiedIdentifier(self, identifier: str | None, isIndex: bool = False) str [source]¶
Returns the quoted identifier, prefixed with the schema (if not null), ready for the insertion into a SQL query.
- Parameters:
identifier (Optional[str]) – the identifier to quote.
isIndex (bool = False) – if
True
, the identifier is treated as an index name.
- Return type:
str