#include <userver/storages/sqlite/transaction.hpp>
RAII transaction wrapper, auto-ROLLBACKs on destruction if no prior Commit
/Rollback
call was made.
This type can't be constructed in user code and is always retrieved from storages::sqlite::Client
Definition at line 24 of file transaction.hpp.
Public Member Functions | |
Transaction (std::shared_ptr< infra::ConnectionPtr > connection, const settings::TransactionOptions &options) | |
Transaction (const Transaction &other)=delete | |
Transaction (Transaction &&other) noexcept | |
Transaction & | operator= (Transaction &&) noexcept |
template<typename... Args> | |
ResultSet | Execute (const Query &query, const Args &... args) const |
Executes a statement. | |
template<typename T> | |
ResultSet | ExecuteDecompose (const Query &query, const T &row) const |
Executes a statement, decomposing the row. | |
template<typename Container> | |
void | ExecuteMany (const Query &query, const Container ¶ms) const |
Executes a statement multiple times. | |
template<typename T, typename... Args> | |
CursorResultSet< T > | GetCursor (std::size_t batch_size, const Query &query, const Args &... args) const |
Executes a statement and returns a cursor for iterating over results. | |
Savepoint | Save (std::string name) const |
Creates a savepoint with specified name. | |
void | Commit () |
Commit the transaction. | |
void | Rollback () |
Rollback the transaction. | |
ResultSet storages::sqlite::Transaction::Execute | ( | const Query & | query, |
const Args &... | args ) const |
Executes a statement.
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.
Args | Types of parameters to bind |
query | SQL query to execute |
args | Parameters to bind to the query |
Definition at line 111 of file transaction.hpp.
ResultSet storages::sqlite::Transaction::ExecuteDecompose | ( | const Query & | query, |
const T & | row ) const |
Executes a statement, 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.
T | Type of the row to decompose |
query | SQL query to execute |
row | Row object to decompose and bind |
Definition at line 124 of file transaction.hpp.
void storages::sqlite::Transaction::ExecuteMany | ( | const Query & | query, |
const Container & | params ) const |
Executes a statement multiple times.
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.
Container | Type of the container holding rows |
query | SQL query to execute |
params | Container of rows to bind and execute |
Definition at line 137 of file transaction.hpp.
CursorResultSet< T > storages::sqlite::Transaction::GetCursor | ( | std::size_t | batch_size, |
const Query & | query, | ||
const Args &... | args ) const |
Executes a statement and returns a cursor for iterating over results.
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.
T | Type of the result rows |
Args | Types of parameters to bind |
batch_size | Number of rows to fetch per batch |
query | SQL query to execute |
args | Parameters to bind to the query |
Definition at line 152 of file transaction.hpp.
Savepoint storages::sqlite::Transaction::Save | ( | std::string | name | ) | const |
Creates a savepoint with specified name.
name | Name of the savepoint |