# Storage backends

> Where turns live: in the process, a SQLite file, Postgres, MongoDB or your own store.

Choose a memory store for llmslim.memory, llmslim serve and llmslim mcp: InMemoryStore, SQLite, Postgres, MongoDB, or any object with the MemoryStore methods.

Category: Guides & Strategies · Version: 0.12 · Updated: November 2026 · 5 min read

## Choose a store

Pass a store, a SQLite path or a database URL as the first argument of `Memory`, or as `--db` (or `LLMSLIM_MEMORY_DB`) to `llmslim serve` and `llmslim mcp`.

| Store | Use |
|---|---|
| `InMemoryStore()` | Tests and short-lived agents; the default for `Memory()`. |
| `SQLiteStore(path)` | One file, Python's built-in `sqlite3`, safe across threads. `Memory("memory.db")` uses it. |
| `PostgresStore(url)` | Postgres 12+ (self-hosted, Supabase, Neon, RDS) through psycopg 3, for several processes or machines. `Memory("postgresql://...")` uses it. `pip install "llmslim[postgres]"`. |

> **Coming in 1.0:** A MongoDB store, for MongoDB 6.0+ and Atlas. See [Storage backends](https://www.llmslim.app/docs/1.0/storage-backends#mongodb) in the 1.0 preview.

## SQLite

The default for the command-line tools is `~/.llmslim/memory.db`, shared by `llmslim mcp` and `llmslim serve`. Back the file up if the memory matters.

sqlite.py:

```python
from llmslim.memory import Memory

memory = Memory("memory.db")
```

## Postgres

Pass a URL and the store opens a small connection pool; you can pass your own `psycopg_pool.ConnectionPool`, or an autocommit `psycopg.Connection`, instead. It creates its table (`llmslim_memory`, or `table=...`) and a `<table>_meta` version table if they don't exist, under an advisory lock, so several processes can start at once. Times are stored as `TIMESTAMPTZ` and come back in UTC.

postgres.py:

```python
# pip install "llmslim[postgres]"
from llmslim.memory import Memory

memory = Memory("postgresql://llmslim:<password>@db.example.com:5432/llmslim")
memory.add({"role": "user", "content": "I moved to Pune last month."}, user_id="asha")
print(memory.search("Where did I move to?", user_id="asha").text)
```

terminal:

```bash
pip install "llmslim[server,postgres]"
LLMSLIM_MEMORY_DB="postgresql://llmslim:<password>@db.example.com:5432/llmslim" llmslim serve --host 0.0.0.0
```

Pass the URL in the environment rather than as `--db`, so the password stays out of the process list.

## Your own store

A store only persists and lists turns. Any object with the `MemoryStore` methods works, so another database can plug in without changing selection:

- `add(items)`, `list(scope, since=None, until=None)` (oldest first), `get(item_id)`;
- `update(item_id, content=None, metadata=None)`, `delete(item_id)`, `delete_scope(scope)`.

The signatures are in the [API reference](https://www.llmslim.app/docs/api-llmslim-memory).

## FAQ

### Does the store change what search returns?

No. A store only persists and lists turns; selection is the same on every store.

### Can several processes share one memory?

A few processes on one host can share a SQLite file. For more, or for servers on several hosts, use Postgres.

## Related

- [Python quickstart](https://www.llmslim.app/docs/quickstart-python.md)
- [HTTP quickstart](https://www.llmslim.app/docs/quickstart-http.md)

Canonical page: https://www.llmslim.app/docs/storage-backends
