userver: storages::sqlite::Client Class Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
storages::sqlite::Client Class Referencefinal

#include <userver/storages/sqlite/client.hpp>

Detailed Description

Interface for executing queries on SQLite connection. Usually retrieved from components::SQLite.

Definition at line 30 of file client.hpp.

Public Member Functions

 Client (const settings::SQLiteSettings &settings, engine::TaskProcessor &blocking_task_processor)
 Client constructor.
 
 ~Client ()
 Client destructor.
 
template<typename... Args>
ResultSet Execute (OperationType operation_type, const Query &query, const Args &... args) const
 Executes a statement with provided operation type.
 
template<typename T>
ResultSet ExecuteDecompose (OperationType operation_type, const Query &query, const T &row) const
 Executes a statement with provided operation type, decomposing the row.
 
template<typename Container>
void ExecuteMany (OperationType operation_type, const Query &query, const Container &params) const
 Executes a statement multiple times with provided operation type.
 
Transaction Begin (OperationType operation_type, const settings::TransactionOptions &options) const
 Begins a transaction with specified operation type and options.
 
Savepoint Save (OperationType operation_type, std::string name) const
 Creates a savepoint with specified operation type and name.
 
template<typename T, typename... Args>
CursorResultSet< T > GetCursor (OperationType operation_type, std::size_t batch_size, const Query &query, const Args &... args) const
 Executes a statement and returns a lazy cursor for batched result retrieval.
 
void WriteStatistics (utils::statistics::Writer &writer) const
 Writes client statistics to the provided writer.
 

Member Function Documentation

◆ Begin()

Transaction storages::sqlite::Client::Begin ( OperationType operation_type,
const settings::TransactionOptions & options ) const

Begins a transaction with specified operation type and options.

Parameters
operation_typeType of the operation (e.g., Read, Write)
optionsTransaction options
Returns
Transaction object representing the started transaction

◆ Execute()

template<typename... Args>
ResultSet storages::sqlite::Client::Execute ( OperationType operation_type,
const Query & query,
const Args &... args ) const

Executes a statement with provided operation type.

Fills placeholders of the statement with args..., Args are expected to be of supported types. See SQLite supported types for better understanding of Args requirements.

Template Parameters
ArgsTypes of parameters to bind
Parameters
operation_typeType of the operation (e.g., Read, Write)
querySQL query to execute
argsParameters to bind to the query
Returns
ResultSet containing the results of the query

Definition at line 130 of file client.hpp.

◆ ExecuteDecompose()

template<typename T>
ResultSet storages::sqlite::Client::ExecuteDecompose ( OperationType operation_type,
const Query & query,
const T & row ) const

Executes a statement with provided operation type, decomposing the row.

Decomposes the fields of the row and binds them as parameters to the query. See SQLite supported types for better understanding of T requirements.

Template Parameters
TType of the row to decompose
Parameters
operation_typeType of the operation (e.g., Read, Write)
querySQL query to execute
rowRow object to decompose and bind
Returns
ResultSet containing the results of the query

Definition at line 143 of file client.hpp.

◆ ExecuteMany()

template<typename Container>
void storages::sqlite::Client::ExecuteMany ( OperationType operation_type,
const Query & query,
const Container & params ) const

Executes a statement multiple times with provided operation type.

Iterates over the container and executes the query for each element. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See MySQL supported types for better understanding of Container::value_type requirements.

Template Parameters
ContainerType of the container holding rows
Parameters
operation_typeType of the operation (e.g., Read, Write)
querySQL query to execute
paramsContainer of rows to bind and execute

Definition at line 156 of file client.hpp.

◆ GetCursor()

template<typename T, typename... Args>
CursorResultSet< T > storages::sqlite::Client::GetCursor ( OperationType operation_type,
std::size_t batch_size,
const Query & query,
const Args &... args ) const

Executes a statement and returns a lazy cursor for batched result retrieval.

This cursor combines execution and iteration: it fetches up to batch_size rows on each step, loading data on demand rather than all at once. Placeholders in the statement are filled with args..., which must be of supported types. See SQLite supported types for detailed mapping of Args.

Template Parameters
TType of each result row
ArgsParameter types to bind
Parameters
operation_typeHint for selecting the connection pool (e.g., ReadOnly, ReadWrite)
batch_sizeNumber of rows to fetch per iteration
querySQL query to execute
argsParameters to bind to the query
Returns
CursorResultSet<T> lazily delivering rows in batches

Definition at line 172 of file client.hpp.

◆ Save()

Savepoint storages::sqlite::Client::Save ( OperationType operation_type,
std::string name ) const

Creates a savepoint with specified operation type and name.

Parameters
operation_typeType of the operation (e.g., Read, Write)
nameName of the savepoint
Returns
Savepoint object representing the created savepoint

◆ WriteStatistics()

void storages::sqlite::Client::WriteStatistics ( utils::statistics::Writer & writer) const

Writes client statistics to the provided writer.

Parameters
writerStatistics writer to output the statistics

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