Use this file to discover all available pages before exploring further.
The Narrator CLI provides database management tools for the Narrator storage system. It includes commands for initializing database tables and checking database status.
Initialize database tables for thread and message storage:
# Initialize with explicit database URLuv run narrator init --database-url "postgresql+asyncpg://user:pass@localhost/dbname"# Initialize using environment variableexport NARRATOR_DATABASE_URL="postgresql+asyncpg://user:pass@localhost/dbname"uv run narrator init
This command creates the necessary database tables:
Check database connection and display basic statistics:
# Check status with explicit database URLuv run narrator status --database-url "postgresql+asyncpg://user:pass@localhost/dbname"# Check status using environment variableexport NARRATOR_DATABASE_URL="postgresql+asyncpg://user:pass@localhost/dbname"uv run narrator status
# Start with defaults (port 5432, detached)uv run narrator docker-start# Use a custom portuv run narrator docker-start --port 5433# Run in foreground (useful for debugging)uv run narrator docker-start --no-detach
The fastest way to get started with PostgreSQL for Narrator:
# One command to set up everythinguv run narrator docker-setup# This will:# 1. Start a PostgreSQL container# 2. Wait for it to be ready# 3. Initialize the database tables# 4. Show you the connection string# The database is now available at:# postgresql+asyncpg://narrator:narrator_dev@localhost:5432/narrator
# PostgreSQL (recommended for production)postgresql+asyncpg://user:password@localhost:5432/dbname# SQLite (good for development)sqlite+aiosqlite:///path/to/database.db# In-memory (default, no persistence)# Just omit the database URL
# 1. Navigate to your projectcd my-tyler-project# 2. Set up local PostgreSQL with Docker (default settings)uv run narrator docker-setup# 3. Use in your codeexport NARRATOR_DATABASE_URL="postgresql+asyncpg://narrator:narrator_dev@localhost:5432/narrator"python your_agent.py
# Set custom database configurationexport NARRATOR_DB_NAME=myappexport NARRATOR_DB_USER=myapp_userexport NARRATOR_DB_PASSWORD=secure_passwordexport NARRATOR_DB_PORT=5433# Start Docker with these settingsuv run narrator docker-setup# Your database will be available at:# postgresql+asyncpg://myapp_user:secure_password@localhost:5433/myapp
# 1. Set production database URLexport NARRATOR_DATABASE_URL="postgresql+asyncpg://prod_user:prod_pass@prod_host:5432/prod_db"# 2. Initialize tables (one-time setup)uv run narrator init# 3. Verify connectionuv run narrator status
from tyler import Agent, ThreadStore# The database must be initialized first with:# uv run narrator init# Then use in your agentthread_store = await ThreadStore.create( "postgresql+asyncpg://narrator:narrator_dev@localhost:5432/narrator")agent = Agent( name="my-agent", thread_store=thread_store)
“Failed to connect to database”: Check your database URL and ensure the database server is running:
# For Docker setup, ensure container is runningdocker ps | grep narrator-postgres# Test connection with psqlpsql postgresql://narrator:narrator_dev@localhost:5432/narrator
“No such command ‘init’”: Make sure you’re using the correct command:
# Correctuv run narrator init# Incorrect (old command name)uv run narrator-db init
“No database URL provided”: Set the environment variable:
# Bash/Zshexport NARRATOR_DATABASE_URL="your-database-url"# Or use .env file with python-dotenvecho 'NARRATOR_DATABASE_URL="your-database-url"' >> .env