QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsAbstractDatabaseProviderConnection::QueryResult Struct Reference

The QueryResult class represents the result of a query executed by execSql() More...

#include <qgsabstractdatabaseproviderconnection.h>

Public Member Functions

QStringList columns () const
 Returns the column names.
 
long long fetchedRowCount () const
 Returns the number of fetched rows.
 
bool hasNextRow () const
 Returns true if there are more rows to fetch.
 
QList< QVariant > nextRow () const
 Returns the next result row or an empty row if there are no rows left.
 
long long rowCount () const
 Returns the number of rows returned by a SELECT query or Qgis::FeatureCountState::UnknownCount if unknown.
 
QList< QList< QVariant > > rows (QgsFeedback *feedback=nullptr)
 Returns the result rows by calling the iterator internally and fetching all the rows, an optional feedback can be used to interrupt the fetching loop.
 

Detailed Description

The QueryResult class represents the result of a query executed by execSql()

It encapsulates an iterator over the result rows and a list of the column names.

Rows can be retrieved by iterating over the result with hasNextRow() and nextRow() or by calling rows() that will internally iterate over the results and return the whole result list.

Since
QGIS 3.18

Definition at line 87 of file qgsabstractdatabaseproviderconnection.h.

Member Function Documentation

◆ columns()

QStringList QgsAbstractDatabaseProviderConnection::QueryResult::columns ( ) const

Returns the column names.

◆ fetchedRowCount()

long long QgsAbstractDatabaseProviderConnection::QueryResult::fetchedRowCount ( ) const

Returns the number of fetched rows.

See also
rowCount()

◆ hasNextRow()

bool QgsAbstractDatabaseProviderConnection::QueryResult::hasNextRow ( ) const

Returns true if there are more rows to fetch.

See also
nextRow()
rewind()

◆ nextRow()

QList< QVariant > QgsAbstractDatabaseProviderConnection::QueryResult::nextRow ( ) const

Returns the next result row or an empty row if there are no rows left.

See also
hasNextRow()
rewind()

◆ rowCount()

long long QgsAbstractDatabaseProviderConnection::QueryResult::rowCount ( ) const

Returns the number of rows returned by a SELECT query or Qgis::FeatureCountState::UnknownCount if unknown.

See also
fetchedRowCount()

◆ rows()

QList< QList< QVariant > > QgsAbstractDatabaseProviderConnection::QueryResult::rows ( QgsFeedback feedback = nullptr)

Returns the result rows by calling the iterator internally and fetching all the rows, an optional feedback can be used to interrupt the fetching loop.

Note
calling this function more than one time is not supported: the second call will always return an empty list.

The documentation for this struct was generated from the following file: