added sqlite connection class (progress)

This commit is contained in:
2023-11-07 23:07:49 +01:00
parent f4f5c00eec
commit 715f4dff8f
21 changed files with 645 additions and 73 deletions
+28
View File
@@ -0,0 +1,28 @@
#include "sqlite_error.hpp"
#include <stdexcept>
#include <sstream>
#include <sqlite3.h>
namespace matador::backends::sqlite {
void throw_sqlite_error(int ec, sqlite3 *db, const std::string &source)
{
if (ec != SQLITE_OK) {
std::stringstream msg;
msg << "sqlite error (" << source << "): " << sqlite3_errmsg(db);
throw std::logic_error(msg.str());
}
}
void throw_sqlite_error(int ec, sqlite3 *db, const std::string &source, const std::string &sql)
{
if (ec != SQLITE_OK) {
std::stringstream msg;
msg << "sqlite error (" << source << ", sql: " << sql << "): " << sqlite3_errmsg(db);
throw std::logic_error(msg.str());
}
}
}