from agno.agent import Agent from agno.tools.postgres import PostgresTools agent = Agent( tools=[PostgresTools(db_url="postgresql://user:pass@localhost:5432/db")], markdown=True, ) agent.print_response("Show me all tables in the database")
Create a virtual environment
Terminal
python3 -m venv .venv source .venv/bin/activate
Set your API key
export OPENAI_API_KEY=xxx
Set your database URL
export DATABASE_URL=postgresql://user:pass@localhost:5432/db
Install libraries
pip install -U psycopg2-binary sqlalchemy openai agno
Run Agent
python cookbook/tools/postgres_tools.py