void SqlQuery::reset_and_clear_bindings() { if (_stmt) { SQLITE_DO(sqlite3_reset(_stmt)); SQLITE_DO(sqlite3_clear_bindings(_stmt)); } }
bool SqlDatabase::openHelper( const QString& filename, int sqliteFlags ) { if( isOpen() ) { return true; } sqliteFlags |= SQLITE_OPEN_NOMUTEX; SQLITE_DO( sqlite3_open_v2(filename.toUtf8().constData(), &_db, sqliteFlags, 0) ); if( _errId != SQLITE_OK ) { qDebug() << "Error:" << _error << "for" << filename; close(); return false; } if( !_db ) { qDebug() << "Error: no database for" << filename; return false; } sqlite3_busy_timeout(_db, 5000); return true; }
bool SqlDatabase::openHelper(const QString &filename, int sqliteFlags) { if (isOpen()) { return true; } sqliteFlags |= SQLITE_OPEN_NOMUTEX; SQLITE_DO(sqlite3_open_v2(filename.toUtf8().constData(), &_db, sqliteFlags, 0)); if (_errId != SQLITE_OK) { qCWarning(lcSql) << "Error:" << _error << "for" << filename; if (_errId == SQLITE_CANTOPEN) { qCWarning(lcSql) << "CANTOPEN extended errcode: " << sqlite3_extended_errcode(_db); #if SQLITE_VERSION_NUMBER >= 3012000 qCWarning(lcSql) << "CANTOPEN system errno: " << sqlite3_system_errno(_db); #endif } close(); return false; } if (!_db) { qCWarning(lcSql) << "Error: no database for" << filename; return false; } sqlite3_busy_timeout(_db, 5000); return true; }
bool SqlDatabase::commit() { if( ! _db ) { return false; } SQLITE_DO(sqlite3_exec(_db, "COMMIT", 0, 0, 0)); return _errId == SQLITE_OK; }
bool SqlDatabase::transaction() { if( ! _db ) { return false; } SQLITE_DO(sqlite3_exec(_db, "BEGIN", 0, 0, 0)); return _errId == SQLITE_OK; }
void SqlQuery::finish() { if (!_stmt) return; SQLITE_DO(sqlite3_finalize(_stmt)); _stmt = 0; if (_sqldb) { _sqldb->_queries.remove(this); } }
void SqlDatabase::close() { if( _db ) { SQLITE_DO(sqlite3_close(_db) ); if (_errId != SQLITE_OK) { qWarning() << "ERROR When closing DB" << _error; Q_ASSERT(!"SQLite Close Error"); } _db = 0; } }
void SqlDatabase::close() { if (_db) { foreach (auto q, _queries) { q->finish(); } SQLITE_DO(sqlite3_close(_db)); if (_errId != SQLITE_OK) qCWarning(lcSql) << "Closing database failed" << _error; _db = 0; } }
void SqlQuery::finish() { SQLITE_DO(sqlite3_finalize(_stmt)); _stmt = 0; }
bool SqlQuery::next() { SQLITE_DO(sqlite3_step(_stmt)); return _errId == SQLITE_ROW; }
void SqlQuery::reset() { SQLITE_DO(sqlite3_reset(_stmt)); }