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

# SqliteChannel Quickstart

> Store many agent conversations in one SQLite file, with concurrent writers and SQL queries

`SqliteChannel` keeps each conversation as rows in a SQLite table. One file holds as many conversations as you like, each under its own name. Several threads or processes can post at once, and any SQLite client can query the history.

Reference: [SqliteChannel](https://docs.swarms.world/api/channels/sqlite-channel.md).

## Two agents, one conversation

```python theme={null}
from swarms import Agent, SqliteChannel

channel = SqliteChannel("channels.db", name="ev-batteries")

researcher = Agent(
    agent_name="Researcher",
    system_prompt="You gather facts and figures. Answer in a short bullet list.",
    model_name="gpt-5.4",
    max_loops=1,
    channel=channel,
)
writer = Agent(
    agent_name="Writer",
    system_prompt="You turn the facts in the conversation into a short report.",
    model_name="gpt-5.4",
    max_loops=1,
    channel=channel,
)

task = "Report on the EV battery market."
researcher.run(task)
writer.run(task)

for row in channel.fetch_messages():
    print(f"#{row['id']} {row['created_at']} {row['agent_name']}")
```

`fetch_messages()` returns each row with its `id` and a UTC `created_at` timestamp.

## A concurrent fan-out into one table

`ConcurrentWorkflow` runs its agents in parallel threads. SQLite and the channel's lock serialise the writes.

```python theme={null}
from swarms import Agent, ConcurrentWorkflow, SqliteChannel

angles = ["technology", "regulation", "supply chain"]
agents = [
    Agent(
        agent_name=f"{angle.title().replace(' ', '-')}-Analyst",
        system_prompt=f"Analyse the task from the {angle} angle only.",
        model_name="gpt-5.4",
        max_loops=1,
    )
    for angle in angles
]

channel = SqliteChannel("channels.db", name="q3-ev-outlook")

workflow = ConcurrentWorkflow(agents=agents, channel=channel)
workflow.run("What will shape the EV battery market over the next five years?")

for message in channel.messages():
    print(f"\n[{message['agent_name']}]\n{message['content']}")
```

## MixtureOfAgents with an audit trail

Every worker's answer in every layer is stored, named like `Bull (layer 1/2)`, followed by the aggregator's answer.

```python theme={null}
from swarms import Agent, MixtureOfAgents, SqliteChannel

workers = [
    Agent(agent_name="Bull", system_prompt="Make the strongest case for the investment.", model_name="gpt-5.4", max_loops=1),
    Agent(agent_name="Bear", system_prompt="Make the strongest case against the investment.", model_name="gpt-5.4", max_loops=1),
    Agent(agent_name="Quant", system_prompt="Assess the numbers only.", model_name="gpt-5.4", max_loops=1),
]
aggregator = Agent(
    agent_name="Portfolio-Manager",
    system_prompt="Weigh the analysts' views and give a final recommendation.",
    model_name="gpt-5.4",
    max_loops=1,
)

channel = SqliteChannel("investments.db", name="nvda-2026-11")

moa = MixtureOfAgents(
    agents=workers,
    aggregator_agent=aggregator,
    layers=2,
    channel=channel,
)
print(moa.run("Should we add to our NVIDIA position this quarter?"))

# Only the Bear's arguments, latest last.
for row in channel.fetch_messages():
    if row["agent_name"].startswith("Bear"):
        print(row["agent_name"], row["content"][:120])
```

## One file, one conversation per ticket

Give each conversation its own `name`. Channels with different names share the file but never see each other's messages.

```python theme={null}
from swarms import Agent, SqliteChannel

DB = "support.db"

tickets = {
    "support-1042": "My invoice shows the wrong plan.",
    "support-1043": "I cannot reset my password.",
}

for ticket, text in tickets.items():
    agent = Agent(
        agent_name="Support-Agent",
        system_prompt="Draft a short, friendly first reply to the customer.",
        model_name="gpt-5.4",
        max_loops=1,
        channel=SqliteChannel(DB, name=ticket),
    )
    agent.run(text)

print(SqliteChannel.list_conversations(DB))
# ['support-1042', 'support-1043']
```

To continue a ticket later, in any process, open the same name. The agent reads the earlier turns first:

```python theme={null}
followup = Agent(
    agent_name="Support-Agent",
    model_name="gpt-5.4",
    max_loops=1,
    channel=SqliteChannel(DB, name="support-1042"),
)
followup.run("The customer says they were charged twice. Update your reply.")
```

## MajorityVoting with queryable votes

```python theme={null}
import sqlite3

from swarms import Agent, MajorityVoting, SqliteChannel

voters = [
    Agent(agent_name=f"Reviewer-{i}", model_name="gpt-5.4", max_loops=1)
    for i in range(1, 4)
]

channel = SqliteChannel("votes.db", name="rust-vs-go")

vote = MajorityVoting(agents=voters, channel=channel)
vote.run("Should our new ingestion service be written in Rust or Go? Answer with one word, then one sentence.")

rows = sqlite3.connect("votes.db").execute(
    "SELECT agent_name, substr(content, 1, 60) FROM messages WHERE channel = ? ORDER BY id",
    ("rust-vs-go",),
)
for agent_name, preview in rows:
    print(f"{agent_name:18} {preview}")
```

The rows are the task under `user`, each reviewer's answer, then the `Consensus-Agent`'s verdict.

## Clean up

```python theme={null}
channel.clear()  # Deletes this conversation's rows; other names are untouched
channel.close()  # Closes the connection; the file keeps everything else
```

## Next steps

* [Channels with every structure](https://docs.swarms.world/examples/channels/multi-agent-structures.md)
* [HttpChannel](https://docs.swarms.world/examples/channels/http-channel.md), to share a conversation across machines


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.