32 const size_t cardinality,
33 const bool read_write)
40 const size_t cardinality,
41 const bool read_write,
42 const std::string logger_level)
55 #if defined(HAVE_SQLITE3_H) 63 SQLITE_OPEN_READWRITE,
66 if (rc != SQLITE_OK) {
70 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
76 if (rc == SQLITE_OK) {
97 if (rc != SQLITE_OK) {
98 std::string error = sqlite3_errmsg(db);
104 #elif defined(HAVE_SQLITE_H) 125 #if defined(HAVE_SQLITE3_H) 127 #elif defined(HAVE_SQLITE_H) 137 char* sqlite_error_msg = 0;
139 logger << DEBUG <<
"executing query: " << query <<
endl;
140 #if defined(HAVE_SQLITE3_H) 141 int result = sqlite3_exec(
142 #elif defined(HAVE_SQLITE_H)
143 int result = sqlite_exec(
152 if (result != SQLITE_OK) {
154 if (sqlite_error_msg != 0) {
155 error = sqlite_error_msg;
157 #if defined(HAVE_SQLITE3_H) 158 sqlite3_free(sqlite_error_msg);
159 #elif defined(HAVE_SQLITE_H) 160 # ifdef HAVE_STDLIB_H 161 free(sqlite_error_msg);
164 logger << ERROR <<
"Error executing SQL: '" 166 <<
"' : " << error <<
endl;
183 for (
int i = 0; i < argc; i++) {
184 if (argv[i] != NULL) {
186 ngram.push_back(argv[i]);
196 query_result.push_back(ngram);
bool get_read_write_mode() const
size_t get_cardinality() const
SqliteDatabaseConnector(const std::string db, const size_t cardinality, const bool read_write)
virtual void closeDatabase()
static int callback(void *pArg, int argc, char **argv, char **columnNames)
virtual NgramTable executeSql(const std::string query) const
std::vector< Ngram > NgramTable
virtual void openDatabase()
void createNgramTable(const size_t cardinality) const
~SqliteDatabaseConnector()
std::string get_database_filename() const
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)