helper function for hardcoded queries: this is a simple wrapper for sqlite3_exec() which throws an exception on error.
| 28 | // helper function for hardcoded queries: this is a simple wrapper for |
| 29 | // sqlite3_exec() which throws an exception on error. |
| 30 | void execute_hardcoded(sqlite_api::sqlite3* conn, char const* const query, |
| 31 | char const* const errMsg, |
| 32 | int (*callback)(void*, int, char**, char**) = nullptr, |
| 33 | void* callback_arg = nullptr) |
| 34 | { |
| 35 | char *zErrMsg = nullptr; |
| 36 | int const res = sqlite3_exec(conn, query, callback, callback_arg, &zErrMsg); |
| 37 | |
| 38 | std::unique_ptr<char, void(*)(void*)> zErrMsgPtr(zErrMsg, sqlite3_free); |
| 39 | if (res != SQLITE_OK) |
| 40 | { |
| 41 | throw sqlite3_soci_error(conn, errMsg, zErrMsg); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // overload allowing to pass std::string instead of const char* |
| 46 | void execute_hardcoded(sqlite_api::sqlite3* conn, |
no test coverage detected