pub struct AgentDB { /* private fields */ }Expand description
The main AgentDB connection — your single-file AI database.
Implementations§
Source§impl AgentDB
impl AgentDB
Sourcepub fn open(path: &str) -> Result<Self>
pub fn open(path: &str) -> Result<Self>
Open or create an AgentDB database. Use ":memory:" for tests.
Sourcepub fn vectors(&self) -> VectorStore
pub fn vectors(&self) -> VectorStore
Access the vector store layer
Sourcepub fn memory(&self) -> MemoryGraph
pub fn memory(&self) -> MemoryGraph
Access the memory graph layer
Sourcepub fn fts(&self) -> FullTextStore
pub fn fts(&self) -> FullTextStore
Access the full-text search layer
Sourcepub fn conversations(&self) -> ConversationStore
pub fn conversations(&self) -> ConversationStore
Access the conversation / message-threading layer
Sourcepub fn workflows(&self) -> WorkflowStore
pub fn workflows(&self) -> WorkflowStore
Access the workflow persistence layer
Sourcepub fn traces(&self) -> TraceStore
pub fn traces(&self) -> TraceStore
Access the reasoning-trace layer
Sourcepub fn hybrid_query(&self, q: HybridQuery<'_>) -> Result<Vec<HybridResult>>
pub fn hybrid_query(&self, q: HybridQuery<'_>) -> Result<Vec<HybridResult>>
Run a hybrid graph + vector query
Sourcepub fn execute_params(&self, sql: &str, params: &[&dyn ToSql]) -> Result<usize>
pub fn execute_params(&self, sql: &str, params: &[&dyn ToSql]) -> Result<usize>
Execute a parameterized SQL statement
Sourcepub fn transaction<F, T>(&self, f: F) -> Result<T>
pub fn transaction<F, T>(&self, f: F) -> Result<T>
Run multiple operations atomically inside a single SQLite transaction.
The closure receives a rusqlite::Transaction and may perform any
number of reads or writes. If the closure returns Ok, the transaction
is committed; if it returns Err (or panics), the transaction is rolled
back automatically.
§Example
let db = AgentDB::open(":memory:").unwrap();
db.transaction(|tx| {
tx.execute("INSERT INTO _adb_nodes (id, label, data) VALUES ('x','tag','{}')", [])?;
tx.execute("INSERT INTO _adb_nodes (id, label, data) VALUES ('y','tag','{}')", [])?;
Ok(())
}).unwrap();Sourcepub fn execute_batch(&self, sql: &str) -> Result<()>
pub fn execute_batch(&self, sql: &str) -> Result<()>
Execute one or more semicolon-separated SQL statements as a single
atomic batch. This is a convenience wrapper around
execute_batch that wraps the
statements in an explicit transaction so partial execution is never
visible to other threads.
§Example
let db = AgentDB::open(":memory:").unwrap();
db.execute_batch(
"INSERT INTO _adb_nodes (id,label,data) VALUES ('a','t','{}');
INSERT INTO _adb_nodes (id,label,data) VALUES ('b','t','{}');"
).unwrap();