Move sqlite_utils.h out of utils:: namespace

This commit is contained in:
Eric Harding committed 2018-11-14 19:13:23 -05:00
1 parent e67756d055
commit 2fc4c8bd60
5 files changed
+52 -45

No files matched your search

+11 -6
View File
@@ -3,22 +3,27 @@
#include "bts_assert.h"
#include <cstring>
namespace bts {
namespace utils {
namespace sqlite {
void sqlite3_exec_nofail(sqlite3* db, const char* sql) {
void exec_nofail(sqlite3* db, const char* sql) {
char* error_message = nullptr;
int result = sqlite3_exec(db, sql, nullptr, nullptr, &error_message);
bts_assert_msg(result == SQLITE_OK, error_message);
}
void sqlite3_exec_nofail(sqlite3_ptr & db, const char * sql) {
return sqlite3_exec_nofail(db.get(), sql);
void exec_nofail(sqlite3_ptr & db, const char * sql) {
return exec_nofail(db.get(), sql);
}
sqlite3_ptr open_db(const char* path) {
sqlite3* temp;
bts_assert(sqlite3_open(path, &temp) == SQLITE_OK);
return sqlite3_ptr(temp, sqlite3_close);
if (sqlite3_open(path, &temp) == SQLITE_OK) {
return sqlite3_ptr(temp, sqlite3_close);
}
else {
LOG(Gen, Error, "Failed to open database {}", std::string(path));
return null_db();
}
}
sqlite3_stmt_ptr prepare_query(sqlite3 * db, const char * query) {