Phidata supports using Sqlite as a storage backend for Agents using the SqlAgentStorage class.

Usage

You need to provide either db_url, db_file or db_engine. The following example uses db_file.

storage.py
from phi.storage.agent.sqlite import SqlAgentStorage

# Create a storage backend using the Sqlite database
storage = SqlAgentStorage(
    # store sessions in the ai.sessions table
    table_name="agent_sessions",
    # db_file: Sqlite database file
    db_file="tmp/data.db",
)

# Add storage to the Agent
agent = Agent(storage=storage)

Params

ParameterTypeDefaultDescription
table_namestr-Name of the table to be used.
schemaOptional[str]"ai"Schema name, default is "ai".
db_urlOptional[str]NoneDatabase URL, if provided.
db_engineOptional[Engine]NoneDatabase engine to be used.
schema_versionint1Version of the schema, default is 1.
auto_upgrade_schemaboolFalseIf true, automatically upgrades the schema when necessary.