8#ifndef DB_EXEC_SQLITE_H
9#define DB_EXEC_SQLITE_H
32 int selectToInt(
const string & i_sql,
int i_default)
override;
35 long long selectToLong(
const string & i_sql,
long long i_default)
override;
44 double selectToDouble(
const string & i_sql,
double i_default)
override;
47 vector<string>
selectRowStr(
const string & i_sql)
override;
60 const string & i_sql,
int i_column,
const type_info & i_type,
size_t i_size,
void * io_valueArr
64 size_t update(
const string & i_sql)
override;
73 void commit(
void)
override;
82 void createStatement(
const string & i_sql,
int i_paramCount,
const type_info ** i_typeArr)
override;
95 sqlite3_stmt * theStmt;
100 vector<BindHandler> bindFncVec;
103 void cleanup(
void)
noexcept override;
106 void validateConnectionProps(
void)
override;
109 template <
typename TCvt>
110 TCvt selectTo(
const string & i_sql,
const TCvt & i_default, TCvt (
DbExecSqlite::*ToRetType)(
int));
113 template <
typename TCol>
114 size_t retrieveColumnTo(
int i_column,
size_t i_size,
void* io_valueArr, TCol (
DbExecSqlite::*ToRetType)(
int));
117 void bindLong(
int i_position,
const DbValue & i_value);
120 template<
typename TDbl>
121 void bindDbl(
int i_position,
const DbValue & i_value);
124 void bindBool(
int i_position,
const DbValue & i_value);
127 void bindStr(
int i_position,
const DbValue & i_value);
130 template<
typename TInt> TInt fieldToInt(
int i_column);
131 template<
typename TDbl> TDbl fieldToDbl(
int i_column);
132 string fieldToStr(
int i_column);
133 int64_t fieldToInt64(
int i_column);
134 double fieldToDouble(
int i_column);
135 bool fieldToBool(
int i_column);
138 template<
typename TInt>
142 template<
typename TDbl>
157 typedef void (DbExecSqlite::*SetFieldHandler)(IRowBase *, int,
const IRowAdapter &);
base class for database connection wrapper
Definition: dbExecBase.h:20
static void runSqlScript(IDbExec *i_dbExec, const string &i_sqlScript)
parse and execute list of sql statements.
Definition: dbExecBase.cpp:199
bool isTransaction(void)
return true in transaction scope.
Definition: dbExecBase.cpp:33
db connection wrapper for SQLite.
Definition: dbExecSqlite.h:20
void createStatement(const string &i_sql, int i_paramCount, const type_info **i_typeArr) override
create new statement with specified parameters.
Definition: dbExecSqlite.cpp:768
void runSqlScript(const string &i_sqlScript) override
parse and execute list of sql statements.
Definition: dbExecSqlite.h:91
~DbExecSqlite(void) noexcept
close db-connection and cleanup connection resources.
Definition: dbExecSqlite.cpp:77
void beginTransaction(void) override
begin transaction, throw exception if transaction already active or statement is active.
Definition: dbExecSqlite.cpp:642
bool isTransaction(void) override
return true in transaction scope.
Definition: dbExecSqlite.h:79
unique_lock< recursive_mutex > beginTransactionThreaded(void) override
begin transaction in multi-threaded environment, throw exception if transaction already active or sta...
Definition: dbExecSqlite.cpp:671
vector< string > selectRowStr(const string &i_sql) override
select string vector of first row or empty vector if no rows, empty "" string used for NULLs.
Definition: dbExecSqlite.cpp:292
bool selectToBool(const string &i_sql) override
select boolean value of first (row,column) or false if no rows or value IS NULL.
Definition: dbExecSqlite.cpp:228
DbExecSqlite(const string &i_connectionStr)
create new db-connection.
Definition: dbExecSqlite.cpp:27
void executeStatement(int i_paramCount, const DbValue *i_valueArr) override
execute statement with parameters.
Definition: dbExecSqlite.cpp:860
void selectToRowProcessor(const string &i_sql, const IRowAdapter &i_adapter, IRowProcessor &i_processor) override
select and process rows: each row created by row adapter and passed to processor.
Definition: dbExecSqlite.cpp:366
void releaseStatement(void) noexcept override
release statement resources.
Definition: dbExecSqlite.cpp:116
int selectToInt(const string &i_sql, int i_default) override
select integer value of first (row,column) or default if no rows or value IS NULL.
Definition: dbExecSqlite.cpp:191
void rollback(void) override
rollback transaction, does nothing if no active transaction, throw exception if statement is active.
Definition: dbExecSqlite.cpp:719
void commit(void) override
commit transaction, does nothing if no active transaction, throw exception if statement is active.
Definition: dbExecSqlite.cpp:688
size_t selectColumn(const string &i_sql, int i_column, const type_info &i_type, size_t i_size, void *io_valueArr) override
select column into io_valueArray[i_size] buffer and return row count.
Definition: dbExecSqlite.cpp:522
IRowBaseList selectRowList(const string &i_sql, const IRowAdapter &i_adapter) override
select list of rows, each row created and field values set by row adapter.
Definition: dbExecSqlite.cpp:358
double selectToDouble(const string &i_sql, double i_default) override
select double value of first (row,column) or default if no rows or value IS NULL.
Definition: dbExecSqlite.cpp:241
string provider(void) const override
return sql provider name, e.g.
Definition: dbExecSqlite.h:29
IRowBaseVec selectRowVector(const string &i_sql, const IRowAdapter &i_adapter) override
select vector of rows, each row created and field values set by row adapter.
Definition: dbExecSqlite.cpp:343
string selectToStr(const string &i_sql) override
select string value of first (row,column) or empty "" string if no rows or value IS NULL.
Definition: dbExecSqlite.cpp:216
long long selectToLong(const string &i_sql, long long i_default) override
select long value of first (row,column) or default if no rows or value IS NULL.
Definition: dbExecSqlite.cpp:204
size_t update(const string &i_sql) override
execute sql statement (update, insert, delete, create, etc).
Definition: dbExecSqlite.cpp:616
database connection wrapper to execute sql commands.
Definition: dbExec.h:21
row factory and setter interface to select row from database
Definition: dbCommon.h:45
public interafce for row processing during select, ie: select and append to row list
Definition: dbCommon.h:181
OpenM++ data library: public interface.
OpenM++ data library: common classes for db connection wrapper.
openM++ namespace
Definition: log.h:32
const char * SQLITE_DB_PROVIDER
SQLite db-provider name.
Definition: dbExec.cpp:14
std::list< IRowBaseUptr > IRowBaseList
db rows: list of unique pointers to db row
Definition: omHelper.h:242
std::vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:239
db-row abstract base
Definition: omHelper.h:231
union to pass value to database methods
Definition: dbCommon.h:73