MySQL for Team
Kern supports using MySQL as a storage backend for Teams using the MySQLDb class.
Usage
Run MySQL
Install docker desktop and run MySQL on port 3306 using:
1docker run -d \2 --name mysql \3 -e MYSQL_ROOT_PASSWORD=ai \4 -e MYSQL_DATABASE=ai \5 -e MYSQL_USER=ai \6 -e MYSQL_PASSWORD=ai \7 -p 3306:3306 \8 -d mysql:81from typing import List23from kern.agent import Agent4from kern.db.mysql import MySQLDb5from kern.models.openai import OpenAIResponses6from kern.team import Team7from kern.tools.hackernews import HackerNewsTools8from kern.tools.hackernews import HackerNewsTools9from pydantic import BaseModel1011# MySQL connection settings12db_url = "mysql+pymysql://ai:ai@localhost:3306/ai"13db = MySQLDb(db_url=db_url)1415class Article(BaseModel):16 title: str17 summary: str18 reference_links: List[str]1920hn_researcher = Agent(21 name="HackerNews Researcher",22 model=OpenAIResponses(id="gpt-5.2"),23 role="Gets top stories from hackernews.",24 tools=[HackerNewsTools()],25)2627web_searcher = Agent(28 name="Web Searcher",29 model=OpenAIResponses(id="gpt-5.2"),30 role="Searches the web for information on a topic",31 tools=[HackerNewsTools()],32 add_datetime_to_context=True,33)3435hn_team = Team(36 name="HackerNews Team",37 model=OpenAIResponses(id="gpt-5.2"),38 members=[hn_researcher, web_searcher],39 db=db,40 instructions=[41 "First, search hackernews for what the user is asking about.",42 "Then, ask the web searcher to search for each story to get more information.",43 "Finally, provide a thoughtful and engaging summary.",44 ],45 output_schema=Article,46 markdown=True,47 show_members_responses=True,48)4950hn_team.print_response("Write an article about the top 2 stories on hackernews")Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_engine | Optional[Engine] | - | The SQLAlchemy database engine to use. |
db_schema | Optional[str] | - | The database schema to use. |
db_url | Optional[str] | - | The database URL to connect to. |
session_table | Optional[str] | - | Name of the table to store Agent, Team and Workflow sessions. |
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. |