Skip to main content
Agno supports using PostgreSQL as a database with the PostgresDb class.

Usage

Install the sqlalchemy, psycopg, and openai packages:
postgres_for_agent.py

Run Postgres (with PgVector)

Install docker desktop and run PgVector on port 5532 using:

Params

ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
db_urlOptional[str]-The database URL to connect to.
db_engineOptional[Engine]-The SQLAlchemy database engine to use.
db_schemaOptional[str]-The database schema to use.
session_tableOptional[str]-Name of the table to store Agent, Team and Workflow sessions.
memory_tableOptional[str]-Name of the table to store memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs data.
knowledge_tableOptional[str]-Name of the table to store knowledge content.
culture_tableOptional[str]-Name of the table to store cultural knowledge.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.
versions_tableOptional[str]-Name of the table to store schema versions.
components_tableOptional[str]-Name of the table to store components.
component_configs_tableOptional[str]-Name of the table to store component configurations.
component_links_tableOptional[str]-Name of the table to store links between components.
learnings_tableOptional[str]-Name of the table to store learnings.
schedules_tableOptional[str]-Name of the table to store cron schedules.
schedule_runs_tableOptional[str]-Name of the table to store schedule run history.
approvals_tableOptional[str]-Name of the table to store human approval requests.
auth_tokens_tableOptional[str]-Name of the table to store OAuth tokens for external services.
service_accounts_tableOptional[str]-Name of the table to store service accounts.
mcp_oauth_clients_tableOptional[str]-Name of the table to store MCP OAuth client registrations.
mcp_oauth_transactions_tableOptional[str]-Name of the table to store MCP OAuth transactions.
mcp_oauth_codes_tableOptional[str]-Name of the table to store MCP OAuth authorization codes.
mcp_oauth_refresh_tokens_tableOptional[str]-Name of the table to store MCP OAuth refresh tokens.
mcp_oauth_keys_tableOptional[str]-Name of the table to store MCP OAuth signing keys.
create_schemaboolTrueWhether to create the database schema if it doesn't exist. Set to False when the schema is managed externally.