Code

cookbook/agent_concepts/tools/postgres_tools.py
from agno.agent import Agent
from agno.tools.postgres import PostgresTools

agent = Agent(
    tools=[PostgresTools(db_url="postgresql://user:pass@localhost:5432/db")],
    show_tool_calls=True,
    markdown=True,
)
agent.print_response("Show me all tables in the database")

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.

2

Set your database URL

export DATABASE_URL=postgresql://user:pass@localhost:5432/db
3

Install libraries

pip install -U psycopg2-binary sqlalchemy agno
4

Run Agent