Provides PostgreSQL database configuration for agent session history, chat storage, and memory persistence.
agno/db/postgres
Config
Supports two connection patterns: Option 1 — Connection URL:| Field | Type | Required | Default | Description |
|---|---|---|---|---|
connection_url | Field[string] | Yes | — | Full PostgreSQL connection URL. Supports FieldReferences |
username | Field[string] | No | — | Username to inject into the URL (if not already in URL) |
password | Field[string] | No | — | Password to inject into the URL (if not already in URL) |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
host | Field[string] | Yes | — | Database host (IP or hostname) |
port | integer | No | 5432 | Database port |
database | Field[string] | Yes | — | Database name |
username | Field[string] | Yes | — | Database username |
password | Field[string] | Yes | — | Database password |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
db_schema | string | No | "ai" | Database schema for Agno tables |
session_table | string | No | — | Custom table name for sessions |
memory_table | string | No | — | Custom table name for memories |
Outputs
| Field | Type | Description |
|---|---|---|
spec | object | Serialized database spec for runtime reconstruction |
Dependencies
Depends on: Nothing directly, but fields support FieldReferences (e.g., fromgcp/cloudsql outputs).
Depended on by:
agno/agent— in thedbfieldagno/team— in thedbfieldagno/memory/manager— in thedbfieldagno/knowledge— in thecontents_dbfield
Example — Using Cloud SQL outputs
Example — Using connection URL
Notes
- You must provide either
connection_urlorhost+database. When using separate fields,usernameandpasswordare also required. - Credentials in the URL take precedence — if the URL already contains credentials, the separate
username/passwordfields are ignored. - The
db_schemadefaults to"ai". Agno creates tables within this schema automatically at runtime. - This resource is stateless — it does not create the database itself. Use
gcp/cloudsql/databaseto provision the actual database.