14 #include <unordered_map>
16 #include "SQLamarr/db_functions.h"
54 std::unordered_map<std::string, sqlite3_stmt*> m_queries;
55 sqlite3* m_cached_raw_ptr;
60 const std::string& name,
62 const std::string& query
83 const std::string& name,
85 void (*xFunc)(sqlite3_context*,
int, sqlite3_value**)
Abstract interface with helper functions to access an SQLite DB.
sqlite3_stmt * get_statement(const std::string &name, const std::string &query)
Creates or retrieve from cache a statement.
BaseSqlInterface(SQLite3DB &db)
Constructor, acquiring the database without ownership.
void begin_transaction()
Begin an SQL transaction stopping update to disk util end_transaction() is issued
virtual ~BaseSqlInterface()
void invalidate_cache(void)
Invalidate the cache of the queries.
void end_transaction()
End an SQL transaction re-enabling disk updates.
int last_insert_row()
Return the index of the last rows inserted in any table.
void sync_database(const std::string &db_uri)
bool exec_stmt(sqlite3_stmt *)
Execute a statement, possibly throwing an exception on failure.
void using_sql_function(const std::string &name, int argc, void(*xFunc)(sqlite3_context *, int, sqlite3_value **))
Register a static function in DB, enabling usage from SQL.
SQLite3DB & m_database
Reference to the SQLite database (not owned).
A database connection handler easying sharing the DB between C++ and Python.
void update_db_connection(SQLite3DB &old_db, const std::string &db_uri, int flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_URI)
Force synchronization to disk by closing and opening the connection.