Use this file to discover all available pages before exploring further.
DatabaseContextProvider gives agents read/write access to any SQL database via SQLAlchemy. Two tools: query_database for reads, update_database for writes.
from sqlalchemy import create_enginefrom agno.agent import Agentfrom agno.models.openai import OpenAIResponsesfrom agno.context.database import DatabaseContextProvider# Two engines: one read-only, one writablereadonly_engine = create_engine("postgresql://reader:pass@localhost/mydb")sql_engine = create_engine("postgresql://writer:pass@localhost/mydb")db = DatabaseContextProvider( sql_engine=sql_engine, readonly_engine=readonly_engine, schema="public",)agent = Agent( model=OpenAIResponses(id="gpt-5.4"), tools=db.get_tools(), instructions=db.instructions(),)agent.print_response("How many orders were placed last month?")
Both engines are required. The read sub-agent uses readonly_engine exclusively. Even if the model tries to run a write query, the database connection physically cannot execute it.