|
Entropic 2.3.8
Local-first agentic inference engine
|
Thread-safe SQLite database wrapper. More...
#include <entropic/storage/database.h>
Public Member Functions | |
| SqliteDatabase (const std::filesystem::path &db_path) | |
| Construct with database file path. | |
| ~SqliteDatabase () | |
| Destructor — closes connection if open. | |
| SqliteDatabase (const SqliteDatabase &)=delete | |
| SqliteDatabase & | operator= (const SqliteDatabase &)=delete |
| bool | initialize () |
| Initialize database and run pending migrations. | |
| void | close () |
| Close database connection. | |
| bool | is_open () const |
| Check if database is open. | |
| 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 | fetch_one (std::string_view sql, std::function< void(sqlite3_stmt *)> binder, std::function< void(sqlite3_stmt *)> extractor) |
| Fetch a single row. | |
| 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. | |
| sqlite3 * | raw_handle () const |
| Get the underlying sqlite3 handle (for advanced use). | |
Thread-safe SQLite database wrapper.
Opens a SQLite database with SQLITE_OPEN_FULLMUTEX as a safety net. Application-level std::mutex serializes all operations to prevent concurrent access patterns.
Definition at line 42 of file database.h.
|
explicit |
Construct with database file path.
| db_path | Path to SQLite file. Created if absent. |
| db_path | Path to SQLite file. |
Definition at line 165 of file database.cpp.
| entropic::SqliteDatabase::~SqliteDatabase | ( | ) |
| void entropic::SqliteDatabase::close | ( | ) |
| bool entropic::SqliteDatabase::execute | ( | std::string_view | sql, |
| std::function< void(sqlite3_stmt *)> | binder = nullptr |
||
| ) |
Execute a write statement (INSERT, UPDATE, DELETE).
Execute a write statement with optional parameter binding.
| sql | SQL statement with ? placeholders. |
| binder | Function to bind parameters to the prepared statement. |
| sql | SQL statement with ? placeholders. |
| binder | Function to bind parameters. |
Definition at line 269 of file database.cpp.
| bool entropic::SqliteDatabase::execute_raw | ( | std::string_view | sql | ) |
Execute raw SQL (multiple statements, no binding).
| sql | SQL text (may contain multiple semicolon-separated statements). |
| sql | SQL text. |
Definition at line 295 of file database.cpp.
| size_t entropic::SqliteDatabase::fetch_all | ( | std::string_view | sql, |
| std::function< void(sqlite3_stmt *)> | binder, | ||
| std::function< void(sqlite3_stmt *)> | row_handler | ||
| ) |
Fetch all matching rows.
| sql | SQL SELECT statement. |
| binder | Function to bind parameters. |
| row_handler | Called for each result row. |
| sql | SQL SELECT statement. |
| binder | Function to bind parameters. |
| row_handler | Called for each result row. |
Definition at line 353 of file database.cpp.
| bool entropic::SqliteDatabase::fetch_one | ( | std::string_view | sql, |
| std::function< void(sqlite3_stmt *)> | binder, | ||
| std::function< void(sqlite3_stmt *)> | extractor | ||
| ) |
Fetch a single row.
| sql | SQL SELECT statement. |
| binder | Function to bind parameters. |
| extractor | Function to extract columns from result row. |
| sql | SQL SELECT statement. |
| binder | Function to bind parameters. |
| extractor | Function to extract columns from result row. |
Definition at line 322 of file database.cpp.
| bool entropic::SqliteDatabase::initialize | ( | ) |
Initialize database and run pending migrations.
Definition at line 183 of file database.cpp.
| bool entropic::SqliteDatabase::is_open | ( | ) | const |
Check if database is open.
Definition at line 235 of file database.cpp.
| sqlite3 * entropic::SqliteDatabase::raw_handle | ( | ) | const |
Get the underlying sqlite3 handle (for advanced use).
Get the underlying sqlite3 handle.
Definition at line 381 of file database.cpp.