SQLite for Workflow

Store workflow sessions and run history in a local SQLite database with SqliteDb.

SqliteDb stores a Workflow's sessions and run history in SQLite.

Usage

Start in a virtual environment.

SqliteDb uses db_engine, then db_url, then db_file. If none is provided, it creates agno.db in the current directory. The following example uses db_file.

Install dependencies:

uv pip install agno openai ddgs sqlalchemy

Set your OpenAI API key:

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.

export OPENAI_API_KEY=sk-***
sqlite_for_workflow.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from agno.tools.websearch import WebSearchTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow

db = SqliteDb(db_file="tmp/workflow.db")

# Define agents
hackernews_agent = Agent(
    name="HackerNews Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[HackerNewsTools()],
    role="Extract key insights and content from HackerNews posts",
)
web_agent = Agent(
    name="Web Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[WebSearchTools()],
    role="Search the web for the latest news and trends",
)

# Define research team for complex analysis
research_team = Team(
    name="Research Team",
    members=[hackernews_agent, web_agent],
    instructions="Research tech topics from HackerNews and the web",
)

content_planner = Agent(
    name="Content Planner",
    model=OpenAIResponses(id="gpt-5.2"),
    instructions=[
        "Plan a content schedule over 4 weeks for the provided topic and research content",
        "Ensure that I have posts for 3 posts per week",
    ],
)

# Define steps
research_step = Step(
    name="Research Step",
    team=research_team,
)

content_planning_step = Step(
    name="Content Planning Step",
    agent=content_planner,
)

# Create and use workflow
if __name__ == "__main__":
    content_creation_workflow = Workflow(
        name="Content Creation Workflow",
        description="Automated content creation from blog posts to social media",
        db=db,
        steps=[research_step, content_planning_step],
    )
    content_creation_workflow.print_response(
        input="Recent AI trends",
        markdown=True,
    )

Run the example

Save the code as sqlite_for_workflow.py and run it; SQLite creates the local database file as needed:

python sqlite_for_workflow.py

Parameters

ParameterTypeDefaultDescription
idOptional[str]NoneDatabase ID. Generated when omitted.
db_engineOptional[Engine]NoneSQLAlchemy database engine. Takes precedence over db_url and db_file.
db_urlOptional[str]NoneDatabase URL. Used when db_engine is omitted.
db_fileOptional[str]NoneDatabase file. Creates ./agno.db when no connection option is provided.
session_tableOptional[str]NoneTable for Agent, Team, and Workflow sessions. Uses "agno_sessions" when omitted.
runs_tableOptional[str]NoneStorage name for individual runs. Defaults to agno_runs, or <session_table>_runs when a custom session name is supplied.
memory_tableOptional[str]NoneTable for user memories. Uses "agno_memories" when omitted.
metrics_tableOptional[str]NoneTable for metrics. Uses "agno_metrics" when omitted.
eval_tableOptional[str]NoneTable for evaluation run data. Uses "agno_eval_runs" when omitted.
knowledge_tableOptional[str]NoneTable for knowledge documents. Uses "agno_knowledge" when omitted.
traces_tableOptional[str]NoneTable for traces. Uses "agno_traces" when omitted.
spans_tableOptional[str]NoneTable for spans. Uses "agno_spans" when omitted.
versions_tableOptional[str]NoneTable for schema versions. Uses "agno_schema_versions" when omitted.
components_tableOptional[str]NoneTable for components. Uses "agno_components" when omitted.
component_configs_tableOptional[str]NoneTable for component configurations. Uses "agno_component_configs" when omitted.
component_links_tableOptional[str]NoneTable for component links. Uses "agno_component_links" when omitted.
learnings_tableOptional[str]NoneTable for learnings. Uses "agno_learnings" when omitted.
schedules_tableOptional[str]NoneTable for cron schedules. Uses "agno_schedules" when omitted.
schedule_runs_tableOptional[str]NoneTable for schedule run history. Uses "agno_schedule_runs" when omitted.
approvals_tableOptional[str]NoneTable for human approval requests. Uses "agno_approvals" when omitted.
auth_tokens_tableOptional[str]NoneTable for OAuth tokens. Uses "agno_auth_tokens" when omitted.
service_accounts_tableOptional[str]NoneTable for service accounts. Uses "agno_service_accounts" when omitted.
mcp_oauth_clients_tableOptional[str]NoneTable for MCP OAuth client registrations. Uses "agno_mcp_oauth_clients" when omitted.
mcp_oauth_transactions_tableOptional[str]NoneTable for MCP OAuth transactions. Uses "agno_mcp_oauth_transactions" when omitted.
mcp_oauth_codes_tableOptional[str]NoneTable for MCP OAuth authorization codes. Uses "agno_mcp_oauth_codes" when omitted.
mcp_oauth_refresh_tokens_tableOptional[str]NoneTable for MCP OAuth refresh tokens. Uses "agno_mcp_oauth_refresh_tokens" when omitted.
mcp_oauth_keys_tableOptional[str]NoneTable for MCP OAuth signing keys. Uses "agno_mcp_oauth_keys" when omitted.