31 static IDbExec *
create(
const string & i_sqlProvider,
const string & i_connectionStr);
44 virtual int selectToInt(
const string & i_sql,
int i_default) = 0;
54 virtual long long selectToLong(
const string & i_sql,
long long i_default) = 0;
139 const string & i_sql,
int i_column,
const type_info & i_type,
size_t i_size,
void * io_valueArr
149 virtual size_t update(
const string & i_sql) = 0;
185 virtual void createStatement(
const string & i_sql,
int i_paramCount,
const type_info ** i_typeArr) = 0;
232 static bool isSqlKeyword(
const char * i_keyword,
size_t i_length = 0);
243 static const string makeDbNameSuffix(
int i_id,
const string & i_src,
const string i_digest);
252 static string textTypeName(
const string & i_sqlProvider,
int i_size);
255 static string valueDbType(
const string & i_sqlProvider,
const string & i_typeName,
int i_typeId);
278 const string & i_sqlProvider,
const string & i_tableName,
const string & i_tableBodySql
298 const string & i_sqlProvider,
const string & i_viewName,
const string & i_viewBodySql
338 static const bool isCrc32Name =
true;
339 static const int dbSuffixSize = isCrc32Name ? 8 : 32;
database connection wrapper to execute sql commands.
Definition: dbExec.h:21
virtual void releaseStatement(void) noexcept=0
release statement resources.
static string valueDbType(const string &i_sqlProvider, const string &i_typeName, int i_typeId)
return db type name by model type for specific db provider
Definition: dbExec.cpp:173
static string makeSqlCreateViewReplace(const string &i_sqlProvider, const string &i_viewName, const string &i_viewBodySql)
make sql statement to create or replace view.
Definition: dbExec.cpp:288
virtual unique_lock< recursive_mutex > beginTransactionThreaded(void)=0
begin transaction in multi-threaded environment.
virtual bool selectToBool(const string &i_sql)=0
select boolean value of first (row,column) or false if no rows or value IS NULL.
static list< string > parseListOfProviderNames(const string &i_sqlProviderNames)
return list of provider names from supplied comma or semicolon separated string or exception on inval...
Definition: dbExec.cpp:44
static const int maxDbTableNameSize
max length of db table or view name.
Definition: dbExec.h:237
static bool isValidProviderName(const char *i_sqlProvider)
check if provider name is valid.
Definition: dbExec.cpp:81
virtual vector< string > selectRowStr(const string &i_sql)=0
select string vector of first row or empty vector if no rows, empty "" string used for NULLs.
virtual ~IDbExec(void) noexcept=0
close db-connection and cleanup connection resources.
Definition: dbExec.cpp:41
static string makeSqlCreateTableIfNotExist(const string &i_sqlProvider, const string &i_tableName, const string &i_tableBodySql)
make sql statement to create table if not exists.
Definition: dbExec.cpp:255
virtual void createStatement(const string &i_sql, int i_paramCount, const type_info **i_typeArr)=0
create new statement with specified parameters.
static string makeSqlCommitTransaction(const string &i_sqlProvider)
return sql statement to commit transaction (db-provider specific).
Definition: dbExec.cpp:249
virtual void commit(void)=0
commit transaction, does nothing if no active transaction.
static string makeSqlBeginTransaction(const string &i_sqlProvider)
return sql statement to begin transaction (db-provider specific).
Definition: dbExec.cpp:221
virtual double selectToDouble(const string &i_sql, double i_default)=0
select double value of first (row,column) or default if no rows or value IS NULL.
virtual bool isTransaction(void)=0
return true in transaction scope.
virtual string selectToStr(const string &i_sql)=0
select string value of first (row,column) or empty "" string if no rows or value IS NULL.
virtual size_t selectColumn(const string &i_sql, int i_column, const type_info &i_type, size_t i_size, void *io_valueArr)=0
select column into io_valueArray[i_size] buffer and return row count.
virtual long long selectToLong(const string &i_sql, long long i_default)=0
select long value of first (row,column) or default if no rows or value IS NULL.
static string floatTypeName(const string &i_sqlProvider)
return type name for FLOAT standard sql type
Definition: dbExec.cpp:136
virtual void selectToRowProcessor(const string &i_sql, const IRowAdapter &i_adapter, IRowProcessor &i_processor)=0
select and process rows: each row created by row adapter and passed to processor.
virtual int selectToInt(const string &i_sql, int i_default)=0
select integer value of first (row,column) or default if no rows or value IS NULL.
virtual IRowBaseList selectRowList(const string &i_sql, const IRowAdapter &i_adapter)=0
select list of rows, each row created and field values set by row adapter.
virtual string provider(void) const =0
return sql provider name, e.g.
static const string makeDbNameSuffix(int i_id, const string &i_src, const string i_digest)
make unique part of db table name by using digest or crc32(digest)
Definition: dbExec.cpp:111
virtual void executeStatement(int i_paramCount, const DbValue *i_valueArr)=0
execute statement with parameters.
static string textTypeName(const string &i_sqlProvider, int i_size)
return column type DDL for long VARCHAR columns, use it for len > 255.
Definition: dbExec.cpp:143
virtual IRowBaseVec selectRowVector(const string &i_sql, const IRowAdapter &i_adapter)=0
select vector of rows, each row created and field values set by row adapter.
static string bigIntTypeName(const string &i_sqlProvider)
return type name for BIGINT sql type
Definition: dbExec.cpp:129
virtual void rollback(void)=0
rollback transaction.
virtual size_t update(const string &i_sql)=0
execute sql statement (update, insert, delete, create, etc).
static const string makeDbNamePrefix(int i_id, const string &i_src)
make prefix part of db table name by shorten source name, ie: ageSexProvince = > ageSexPr
Definition: dbExec.cpp:91
static bool isSqlKeyword(const char *i_keyword, size_t i_length=0)
return true if i_keword matched one of SQL reserved keywords, comparison is case neutral and limited ...
Definition: dbExec.cpp:502
virtual void runSqlScript(const string &i_sqlScript)=0
parse and execute list of sql statements.
virtual void beginTransaction(void)=0
begin transaction.
static IDbExec * create(const string &i_sqlProvider, const string &i_connectionStr)
db-connection factory: create new db-connection.
Definition: dbExecProvider.cpp:19
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 for db common structures.
openM++ namespace
Definition: log.h:32
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
OpenM++: public interface for log and trace support.
union to pass value to database methods
Definition: dbCommon.h:73