Supabase
Use Supabase PostgreSQL for agent session storage.
Agno supports using Supabase with the PostgresDb class.
You can get started with Supabase by following their Get Started guide.
You can read more about the PostgresDb class in its section.
Usage
Start in a virtual environment.
Install Agno, SQLAlchemy, the binary Psycopg driver, and the OpenAI client:
uv pip install agno sqlalchemy "psycopg[binary]" openaiUse your project's Connect dialog to copy a PostgreSQL connection string. Choose Direct connection when the Python host has IPv6 connectivity (or your project has the IPv4 add-on); choose the Session pooler for a persistent application on an IPv4-only host. See Connecting to Postgres.
Keep the URL's [YOUR-PASSWORD] placeholder and set the actual password separately. The code below encodes the password for the URL, including characters such as @ or /, and preserves the selected endpoint and query options.
export SUPABASE_DB_URL="paste_the_connection_string_from_Connect"
export SUPABASE_PASSWORD="your_database_password"from agno.agent import Agent
from agno.db.postgres import PostgresDb
from os import environ
from sqlalchemy.engine import make_url
SUPABASE_DB_URL = make_url(environ["SUPABASE_DB_URL"]).set(
drivername="postgresql+psycopg",
password=environ["SUPABASE_PASSWORD"],
).render_as_string(hide_password=False)
# Setup the Supabase database
db = PostgresDb(db_url=SUPABASE_DB_URL)
# Setup your Agent with the Database
agent = Agent(db=db)Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_url | Optional[str] | - | The database URL to connect to. |
db_engine | Optional[Engine] | - | The SQLAlchemy database engine to use. |
db_schema | Optional[str] | - | The database schema to use. |
session_table | Optional[str] | - | Name of the table to store Agent, Team and Workflow sessions. |
runs_table | Optional[str] | - | Name of the table to store the runs of each session. |
memory_table | Optional[str] | - | Name of the table to store memories. |
metrics_table | Optional[str] | - | Name of the table to store metrics. |
eval_table | Optional[str] | - | Name of the table to store evaluation runs data. |
knowledge_table | Optional[str] | - | Name of the table to store knowledge content. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |
versions_table | Optional[str] | - | Name of the table to store schema versions. |
components_table | Optional[str] | - | Name of the table to store components. |
component_configs_table | Optional[str] | - | Name of the table to store component configurations. |
component_links_table | Optional[str] | - | Name of the table to store links between components. |
learnings_table | Optional[str] | - | Name of the table to store learnings. |
schedules_table | Optional[str] | - | Name of the table to store cron schedules. |
schedule_runs_table | Optional[str] | - | Name of the table to store schedule run history. |
job_table | Optional[str] | - | Name of the table to store durable background run jobs. |
approvals_table | Optional[str] | - | Name of the table to store human approval requests. |
auth_tokens_table | Optional[str] | - | Name of the table to store OAuth tokens for external services. |
service_accounts_table | Optional[str] | - | Name of the table to store service accounts. |
mcp_oauth_clients_table | Optional[str] | - | Name of the table to store MCP OAuth client registrations. |
mcp_oauth_transactions_table | Optional[str] | - | Name of the table to store MCP OAuth transactions. |
mcp_oauth_codes_table | Optional[str] | - | Name of the table to store MCP OAuth authorization codes. |
mcp_oauth_refresh_tokens_table | Optional[str] | - | Name of the table to store MCP OAuth refresh tokens. |
mcp_oauth_keys_table | Optional[str] | - | Name of the table to store MCP OAuth signing keys. |
create_schema | bool | True | Whether to create the database schema if it doesn't exist. Set to False when the schema is managed externally. |