87 bool execute(std::string_view sql,
88 std::function<
void(sqlite3_stmt*)> binder =
nullptr);
107 std::function<
void(sqlite3_stmt*)> binder,
108 std::function<
void(sqlite3_stmt*)> extractor);
119 std::function<
void(sqlite3_stmt*)> binder,
120 std::function<
void(sqlite3_stmt*)> row_handler);
135 bool run_migrations();
143 sqlite3_stmt* prepare(std::string_view sql);
145 std::filesystem::path db_path_;
146 sqlite3* db_ =
nullptr;
147 mutable std::mutex mutex_;
Thread-safe SQLite database wrapper.
bool execute(std::string_view sql, std::function< void(sqlite3_stmt *)> binder=nullptr)
Execute a write statement (INSERT, UPDATE, DELETE).
bool execute_raw(std::string_view sql)
Execute raw SQL (multiple statements, no binding).
bool is_open() const
Check if database is open.
void close()
Close database connection.
~SqliteDatabase()
Destructor — closes connection if open.
sqlite3 * raw_handle() const
Get the underlying sqlite3 handle (for advanced use).
size_t fetch_all(std::string_view sql, std::function< void(sqlite3_stmt *)> binder, std::function< void(sqlite3_stmt *)> row_handler)
Fetch all matching rows.
bool fetch_one(std::string_view sql, std::function< void(sqlite3_stmt *)> binder, std::function< void(sqlite3_stmt *)> extractor)
Fetch a single row.
bool initialize()
Initialize database and run pending migrations.
Activate model on GPU (WARM → ACTIVE).