QGIS API Documentation  3.20.0-Odense (decaadbb31)
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. More...
 
qlonglong fetchedRowCount () const
 Returns the number of fetched rows. More...
 
bool hasNextRow () const
 Returns true if there are more rows to fetch. More...
 
QList< QVariant > nextRow () const
 Returns the next result row or an empty row if there are no rows left. More...
 
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. More...
 

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 82 of file qgsabstractdatabaseproviderconnection.h.

Member Function Documentation

◆ columns()

QStringList QgsAbstractDatabaseProviderConnection::QueryResult::columns ( ) const

Returns the column names.

◆ fetchedRowCount()

qlonglong 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()

◆ 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: