SQLite

SQLite requires no server setup and stores data in a local file. It is built into Python, and available in TypeScript via better-sqlite3.

Install

Install
pip install memori openai
# SQLite is built into Python — no extra driver needed.

Quick Start

SQLite Connection
from memori import Memori
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

engine = create_engine("sqlite:///memori.db")
SessionLocal = sessionmaker(bind=engine)

mem = Memori(conn=SessionLocal)
mem.config.storage.build()

Connection Strings (Python)

Path TypeConnection StringDescription
Relativesqlite:///memori.dbFile in current directory
Absolutesqlite:////home/user/data/memori.dbAbsolute path (four slashes)
In-Memorysqlite:///:memory:Temporary, lost on exit

Complete Example

Complete Example
import os
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from memori import Memori
from openai import OpenAI

engine = create_engine("sqlite:///memori.db")
SessionLocal = sessionmaker(bind=engine)

client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
mem = Memori(conn=SessionLocal).llm.register(client)
mem.attribution(entity_id="user_123", process_id="my_agent")
mem.config.storage.build()

response = client.chat.completions.create(
    model="gpt-4.1-mini",
    messages=[{"role": "user", "content": "My favorite language is Python."}]
)
print(response.choices[0].message.content)

mem.augmentation.wait()
facts = mem.recall("favorite programming language")
print(facts)

Multi-Threading (Python)

For web servers or multi-threaded apps, disable the same-thread check:

engine = create_engine(
    "sqlite:///memori.db",
    connect_args={"check_same_thread": False}
)

Notes (TypeScript)

  • better-sqlite3 runs synchronously, which perfectly matches Memori's low-latency design — no async overhead for local storage.
  • Pass a factory function: conn: () => db. Memori calls it once to borrow the database. You own the lifecycle — call db.close() yourself when you're done.
  • Set OPENAI_API_KEY in your .env file.