SQLite prepared statement.
More...
#include <Statement.h>
|
void | reset () |
| Reset prepared statement for re-execution and clear bindings. More...
|
|
bool | step () |
| Step through the prepared statement. More...
|
|
void | bind (int index, std::int64_t value) |
| Bind an integer to a parameter. More...
|
|
template<typename I > |
requires std::integral< I > void | bind (int index, I value) |
|
void | bind (int index, double value) |
| Bind a double to a parameter. More...
|
|
void | bind (int index, std::string_view value) |
| Bind a string to a parameter. More...
|
|
template<ValidColumnType T, std::size_t I> |
T | column () |
| Retrieve a column. More...
|
|
template<ValidColumnType... Ts, std::size_t... Is> |
std::tuple< Ts... > | columns (std::index_sequence< Is... >) |
| Retrieve columns. More...
|
|
SQLite prepared statement.
Definition at line 50 of file Statement.h.
◆ Statement() [1/3]
SQLite::Statement::Statement |
( |
sqlite3 * |
db, |
|
|
std::string_view |
sql, |
|
|
std::source_location |
call |
|
) |
| |
Create a prepared statement attached to an SQLiteDBSvc This class should be constructed using the createStatement member function of SQLiteDBSvc.
Definition at line 12 of file Statement.cxx.
16 sqlite3_prepare_v2(
db,
sql.data(),
int(
sql.size()), &
m_stmt,
nullptr);
18 throw std::logic_error(
19 std::format(
"ERROR preparing SQLite statement: {} ({}) at {} [{}:{}]",
20 sqlite3_errstr(
err), sqlite3_errmsg(
m_db),
◆ ~Statement()
SQLite::Statement::~Statement |
( |
| ) |
|
◆ Statement() [2/3]
SQLite::Statement::Statement |
( |
| ) |
|
|
default |
◆ Statement() [3/3]
◆ bind() [1/4]
void SQLite::Statement::bind |
( |
int |
index, |
|
|
double |
value |
|
) |
| |
|
private |
Bind a double to a parameter.
Definition at line 80 of file Statement.cxx.
83 throw std::tuple<int, int>{
err,
index};
◆ bind() [2/4]
◆ bind() [3/4]
void SQLite::Statement::bind |
( |
int |
index, |
|
|
std::int64_t |
value |
|
) |
| |
|
private |
Bind an integer to a parameter.
Definition at line 73 of file Statement.cxx.
76 throw std::tuple<int, int>{
err,
index};
◆ bind() [4/4]
void SQLite::Statement::bind |
( |
int |
index, |
|
|
std::string_view |
value |
|
) |
| |
|
private |
Bind a string to a parameter.
Definition at line 87 of file Statement.cxx.
89 int(
value.size()), SQLITE_TRANSIENT);
91 throw std::tuple<int, int>{
err,
index};
◆ column()
template<ValidColumnType T, std::size_t I>
T SQLite::Statement::column |
( |
| ) |
|
|
private |
◆ columns()
template<ValidColumnType... Ts, std::size_t... Is>
std::tuple<Ts...> SQLite::Statement::columns |
( |
std::index_sequence< Is... > |
| ) |
|
|
private |
◆ operator=()
Move assignment operator allows Statement member variables to be filled from createStatement.
Definition at line 26 of file Statement.cxx.
◆ reset()
void SQLite::Statement::reset |
( |
| ) |
|
|
private |
Reset prepared statement for re-execution and clear bindings.
Definition at line 44 of file Statement.cxx.
47 throw std::runtime_error(
48 std::format(
"ERROR in SQLite statement reset: {} ({})",
49 sqlite3_errstr(
err), sqlite3_errmsg(
m_db)));
51 sqlite3_clear_bindings(
m_stmt);
◆ run()
template<ValidColumnType... ReturnArgs, ValidParamType... ParamArgs>
◆ step()
bool SQLite::Statement::step |
( |
| ) |
|
|
private |
Step through the prepared statement.
Definition at line 54 of file Statement.cxx.
55 int err = SQLITE_BUSY;
56 while (
err == SQLITE_BUSY) {
65 throw std::runtime_error(
66 std::format(
"ERROR in SQLite statement step: {} ({})",
67 sqlite3_errstr(
err), sqlite3_errmsg(
m_db)));
◆ m_creationPoint
std::source_location SQLite::Statement::m_creationPoint |
|
private |
◆ m_db
sqlite3* SQLite::Statement::m_db = nullptr |
|
private |
◆ m_stmt
sqlite3_stmt* SQLite::Statement::m_stmt = nullptr |
|
private |
◆ m_stmtMutex
std::recursive_mutex SQLite::Statement::m_stmtMutex |
|
private |
The documentation for this class was generated from the following files:
def call(args, bufsize=0, executable=None, stdin=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, message="", logger=msg, loglevel=None, timeout=None, retry=2, timefactor=1.5, sleeptime=10)