Skip to main content

SQLite

SQLite is the simplest option for local development and testing.

Installation

pip install "praisonaiagents[tools]"

Quick Start

from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    instructions="You are a helpful assistant.",
    memory={
        "db": "conversations.db",
        "session_id": "my-session"
    }
)

response = agent.start("Hello!")
print(response)

File Path Options

from praisonaiagents import Agent

# Current directory
agent = Agent(name="Bot", memory={"db": "mydata.db"})

# Absolute path
agent = Agent(name="Bot", memory={"db": "/home/user/data/conversations.db"})

# Subdirectory
agent = Agent(name="Bot", memory={"db": "./data/conversations.db"})

Environment Variables

export PRAISON_CONVERSATION_URL="mydata.db"
import os
from praisonaiagents import Agent

agent = Agent(
    name="Assistant",
    memory={"db": os.getenv("PRAISON_CONVERSATION_URL")}
)

CLI

# Validate connection
praisonai persistence doctor --conversation-url "mydata.db"

# Run with persistence
praisonai persistence run \
    --conversation-url "mydata.db" \
    --session-id "local-session" \
    "Hello!"

When to Use SQLite

Good for:
  • Local development
  • Testing
  • Single-user applications
  • Prototyping
Not recommended for:
  • Production multi-user apps
  • High concurrency
  • Distributed systems

Storage Backend (Advanced)

For training data, sessions, and general persistence, use the SQLiteBackend:
from praisonaiagents.storage import SQLiteBackend, BaseJSONStore

backend = SQLiteBackend(db_path="~/.praisonai/data.db")
store = BaseJSONStore("session.json", backend=backend)
store.save({"messages": ["Hello"]})
data = store.load()

CLI Usage

# Training with SQLite backend
praisonai train agents --input "Hello" --storage-backend sqlite --storage-path ~/.praisonai/train.db

# Session list with SQLite backend
praisonai session list --storage-backend sqlite --storage-path ~/.praisonai/sessions.db
See Storage Backends for more details.

Troubleshooting

File permissions:
# Check if directory is writable
touch test.db && rm test.db
Database locked:
  • SQLite only allows one writer at a time
  • Use PostgreSQL for concurrent access