zoey-storage-sql

Crates.iozoey-storage-sql
lib.rszoey-storage-sql
version0.1.1
created_at2026-01-09 23:57:02.597008+00
updated_at2026-01-09 23:57:02.597008+00
descriptionSQL database adapters (PostgreSQL, SQLite) for ZoeyAI
homepage
repositoryhttps://github.com/Agent-Zoey/Zoey.git
max_upload_size
id2033189
size352,619
Christopher Freytes (Freytes)

documentation

README

Zoey

Always watching over your data

🗄ïļ zoey-storage-sql

Crates.io Documentation License: MIT

SQL storage adapters for ZoeyAI

SQLite and PostgreSQL implementations of the IDatabaseAdapter trait from zoey-core. The default choice for most deployments.

Installation

Add to your Cargo.toml:

[dependencies]
zoey-core = "0.1"
zoey-storage-sql = "0.1"

Features

  • ðŸŠķ SQLite - Zero-config, embedded database (perfect for local/edge)
  • 🐘 PostgreSQL - Production-ready with full SQL capabilities
  • 🔍 Vector Search - pgvector support for PostgreSQL
  • 📊 Migrations - Automatic schema management

Quick Start

SQLite (Recommended for Development)

use zoey_core::{AgentRuntime, RuntimeOpts, IDatabaseAdapter};
use zoey_storage_sql::SqliteAdapter;
use std::sync::Arc;

#[tokio::main]
async fn main() -> zoey_core::Result<()> {
    // In-memory database
    let mut adapter = SqliteAdapter::new(":memory:");
    
    // Or file-based
    // let mut adapter = SqliteAdapter::new("./zoey.db");
    
    adapter.init().await?;
    
    let opts = RuntimeOpts::default()
        .with_adapter(Arc::new(adapter));
    
    let runtime = AgentRuntime::new(opts).await?;
    
    Ok(())
}

PostgreSQL (Recommended for Production)

use zoey_core::{AgentRuntime, RuntimeOpts, IDatabaseAdapter};
use zoey_storage_sql::PostgresAdapter;
use std::sync::Arc;

#[tokio::main]
async fn main() -> zoey_core::Result<()> {
    let mut adapter = PostgresAdapter::new(
        "postgres://user:password@localhost:5432/zoey"
    );
    
    adapter.init().await?;
    
    let opts = RuntimeOpts::default()
        .with_adapter(Arc::new(adapter));
    
    let runtime = AgentRuntime::new(opts).await?;
    
    Ok(())
}

Configuration

Environment Variables

# SQLite
ZOEY_DB_PATH=./zoey.db

# PostgreSQL
DATABASE_URL=postgres://user:password@localhost:5432/zoey

Connection Pooling (PostgreSQL)

let adapter = PostgresAdapter::new_with_pool_size(
    "postgres://localhost/zoey",
    max_connections: 10,
);

Vector Search

PostgreSQL with pgvector

-- Enable pgvector (run once)
CREATE EXTENSION IF NOT EXISTS vector;

SQLite

SQLite uses a simple cosine similarity implementation for vector search. For production vector workloads, consider PostgreSQL with pgvector or zoey-storage-vector.


When to Use Which?

Scenario Recommended
Local development SQLite
Edge/embedded deployment SQLite
Production web service PostgreSQL
High-volume vector search PostgreSQL + pgvector
Serverless Supabase or SQLite

Related Crates

Crate Description
zoey-core Core runtime and IDatabaseAdapter trait
zoey-storage-mongo MongoDB adapter
zoey-storage-supabase Supabase adapter
zoey-storage-vector Local vector storage

License

MIT License - See LICENSE for details.


🔐 Your secrets are safe with Zoey

Commit count: 12

cargo fmt