> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-studio-tools-doc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SQL

> Use SQL tools with Agno agents.

Enable Agno agents to autonomously navigate databases, translate natural language into SQL, and execute queries to provide structured answers.

```python theme={null}

from agno.agent import Agent
from agno.tools.sql import SQLTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

agent = Agent(tools=[SQLTools(db_url=db_url)])

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        "List the tables in the database. Tell me about contents of one of the tables",
        markdown=True,
    )
```

## Run the Example

```bash theme={null}
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools

# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate

python sql_tools.py
```

For details, see [SQL Tools cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/91_tools/sql_tools.py).
