This example shows how to use the Memory class to create a persistent memory.Every time you run this, the Memory object will be re-initialized from the DB.
from typing import Listfrom agno.memory.v2.db.schema import MemoryRowfrom agno.memory.v2.db.sqlite import SqliteMemoryDbfrom agno.memory.v2.memory import Memoryfrom agno.memory.v2.schema import UserMemorymemory_db = SqliteMemoryDb(table_name="memory", db_file="tmp/memory.db")memory = Memory(db=memory_db)john_doe_id = "john_doe@example.com"# Run 1memory.add_user_memory( memory=UserMemory(memory="The user's name is John Doe", topics=["name"]), user_id=john_doe_id,)# Run this the 2nd time# memory.add_user_memory(# memory=UserMemory(memory="The user works at a softward company called Agno", topics=["name"]),# user_id=john_doe_id,# )memories: List[MemoryRow] = memory_db.read_memories()print("All the DB memories:")for i, m in enumerate(memories): print(f"{i}: {m.memory['memory']} ({m.last_updated})")