> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL Agent Storage

## Example

```python storage.py theme={null}
from phi.storage.agent.postgres import PgAgentStorage

# Create a storage backend using the Postgres database
storage = PgAgentStorage(
    # store sessions in the ai.sessions table
    table_name="agent_sessions",
    # db_url: Postgres database URL
    db_url=db_url,
)

# Add storage to the Agent
agent = Agent(storage=storage)
```

## Params

<Snippet file="storage-postgres-params.mdx" />
