41 #include <type_traits>
101 return tableExists(db_, tablename);
118 return columnExists(db_, tablename, colname);
132 executeStatement(db_, statement);
153 executeBindStatement(db_, prepare_statement, data);
169 prepareStatement(db_, stmt, prepare_statement);
270 sqlite3* db_ =
nullptr;
276 namespace SqliteHelper
281 template <
typename T>
284 static_assert(std::is_same<T, std::false_type>::value,
"Wrong input type to clearSignBit(). Please pass unsigned 64bit ints!");
290 return value & ~(1ULL << 63);
338 template <
typename ValueType>
352 template <>
bool extractValue<std::string>(std::string* dst, sqlite3_stmt* stmt,
int pos);
A method or algorithm argument contains illegal values.
Definition: Exception.h:656
File adapter for Sqlite files.
Definition: SqliteConnector.h:57
bool tableExists(const String &tablename)
Checks whether the given table exists.
Definition: SqliteConnector.h:99
~SqliteConnector()
Destructor.
sqlite3 * getDB()
Returns the raw pointer to the database.
Definition: SqliteConnector.h:87
Size countTableRows(const String &table_name)
static bool columnExists(sqlite3 *db, const String &tablename, const String &colname)
Checks whether the given table contains a certain column.
void executeBindStatement(const String &prepare_statement, const std::vector< String > &data)
Executes raw data SQL statements (insert statements)
Definition: SqliteConnector.h:151
SqlOpenMode
how an sqlite db should be opened
Definition: SqliteConnector.h:62
SqliteConnector()=delete
Default constructor.
static bool tableExists(sqlite3 *db, const String &tablename)
Checks whether the given table exists.
SqliteConnector(const String &filename, const SqlOpenMode mode=SqlOpenMode::READWRITE_OR_CREATE)
void openDatabase_(const String &filename, const SqlOpenMode mode)
Opens a new SQLite database.
static void executeBindStatement(sqlite3 *db, const String &prepare_statement, const std::vector< String > &data)
Executes raw data SQL statements (insert statements)
static void prepareStatement(sqlite3 *db, sqlite3_stmt **stmt, const String &prepare_statement)
Converts an SQL statement into a prepared statement.
void prepareStatement(sqlite3_stmt **stmt, const String &prepare_statement)
Prepares a SQL statement.
Definition: SqliteConnector.h:167
bool columnExists(const String &tablename, const String &colname)
Checks whether the given table contains a certain column.
Definition: SqliteConnector.h:116
void executeStatement(const String &statement)
Executes a given SQL statement (insert statement)
Definition: SqliteConnector.h:130
static void executeStatement(sqlite3 *db, const std::stringstream &statement)
Executes a given SQL statement (insert statement)
static void executeStatement(sqlite3 *db, const String &statement)
Executes a given SQL statement (insert statement)
A more convenient string class.
Definition: String.h:61
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
OPENMS_INT64_TYPE Int64
Signed integer type (64bit)
Definition: Types.h:70
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
bool extractBool(sqlite3_stmt *stmt, int pos)
float extractFloat(sqlite3_stmt *stmt, int pos)
convenience function; note: in SQL there is no float, just double. So this might be narrowing.
char extractChar(sqlite3_stmt *stmt, int pos)
Int64 extractInt64(sqlite3_stmt *stmt, int pos)
int extractInt(sqlite3_stmt *stmt, int pos)
String extractString(sqlite3_stmt *stmt, int pos)
double extractDouble(sqlite3_stmt *stmt, int pos)
bool extractValue< String >(String *dst, sqlite3_stmt *stmt, int pos)
SqlState nextRow(sqlite3_stmt *stmt, SqlState current=SqlState::SQL_ROW)
retrieves the next row from a prepared statement
SqlState
Definition: SqliteConnector.h:295
@ SQL_ERROR
includes SQLITE_BUSY, SQLITE_ERROR, SQLITE_MISUSE
bool extractValue< double >(double *dst, sqlite3_stmt *stmt, int pos)
bool extractValue< int >(int *dst, sqlite3_stmt *stmt, int pos)
UInt64 clearSignBit(T)
Definition: SqliteConnector.h:282
bool extractValueIntStr(String *dst, sqlite3_stmt *stmt, int pos)
Special case where an integer should be stored in a String field.
bool extractValue< Int64 >(Int64 *dst, sqlite3_stmt *stmt, int pos)
bool extractValue(ValueType *, sqlite3_stmt *, int)
Extracts a specific value from an SQL column.
Definition: SqliteConnector.h:339
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47