> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Persistent Storage

> Chat with database persistence

## SQLite Persistence

```python theme={null}
import asyncio
from upsonic import Agent, Chat
from upsonic.storage import SqliteStorage


async def main():
    storage = SqliteStorage(db_file="chat.db")
    agent = Agent("anthropic/claude-sonnet-4-5")

    chat = Chat(
        session_id="persistent_session",
        user_id="user1",
        agent=agent,
        storage=storage,
        full_session_memory=True
    )

    response = await chat.invoke("Remember that my favorite color is blue")
    print(response)


if __name__ == "__main__":
    asyncio.run(main())
```

## Resume Previous Session

```python theme={null}
import asyncio
from upsonic import Agent, Chat
from upsonic.storage import SqliteStorage


async def main():
    storage = SqliteStorage(db_file="chat.db")
    agent = Agent("anthropic/claude-sonnet-4-5")

    chat = Chat(
        session_id="persistent_session",
        user_id="user1",
        agent=agent,
        storage=storage,
        full_session_memory=True
    )

    response = await chat.invoke("What is my favorite color?")
    print(response)

    print(f"\nTotal messages: {len(chat.all_messages)}")


if __name__ == "__main__":
    asyncio.run(main())
```
