Class: QgsDatabaseQueryLog

Handles logging of database queries.

QgsDatabaseQueryLog is not usually directly created, but rather accessed through QgsApplication.databaseQueryLog(). Generally, clients should only access the static log() method to register their queries.

Example

# Log a database query
QgsDatabaseQueryLog.log('SELECT * FROM my_table')

Added in version 3.24.

Class Hierarchy

Inheritance diagram of qgis.core.QgsDatabaseQueryLog

Base classes

QObject

Static Methods

enabled

Returns True if logging is enabled.

finished

Records that the database query has finished.

log

Logs a database query as starting.

class qgis.core.QgsDatabaseQueryLog[source]

Bases: QObject

__init__(parent: QObject | None = None)

Creates a new query log.

QgsDatabaseQueryLog is not usually directly created, but rather accessed through QgsApplication.databaseQueryLog().

Parameters:

parent (Optional[QObject] = None)

static enabled() bool[source]

Returns True if logging is enabled.

See also

setEnabled()

Return type:

bool

static finished(query: QgsDatabaseQueryLogEntry)[source]

Records that the database query has finished.

This method can be safely called from any thread.

Parameters:

query (QgsDatabaseQueryLogEntry)

static log(query: QgsDatabaseQueryLogEntry)[source]

Logs a database query as starting.

This method can be safely called from any thread.

Parameters:

query (QgsDatabaseQueryLogEntry)