Skip to main content
Give your Agent a real SQLite file so conversations survive a restart.

Quick Start

1

Durable SQLite (recommended)

2

In-memory (tests only)

Driver requirements. db("sqlite:…") tries two drivers in order: better-sqlite3 (the declared dependency), then Node’s built-in node:sqlite (Node ≥ 22.5, no native build). There is no memory fallback — if neither driver can open the file, every operation rejects with an actionable error.

Which URL Should I Use?

Pick the URL that matches what you need. Only sqlite: and memory: are wired to the Agent’s session/message/run contract today.

Database URL Formats

db("postgres://…") and db("redis://…") throw deliberately. Both back remote-only HTTP transports (Neon, Upstash) that expose query/get/set — not the sessions/messages/runs contract the Agent calls. Their errors point you at db("sqlite:…") as the working durable option. Use the low-level createNeonPostgres / createUpstashRedis factories directly if you need those key/value transports.

Agent with Persistent Memory

Multi-Agent with Shared Database

Session Management

Direct Database Operations

Access the adapter directly for advanced use cases. getMessages(sessionId, limit) returns the last limit messages in chronological order.
Swapping db('memory:') for db('sqlite:./data.db') changes durability and nothing else — same read order, and unset optional fields read back as undefined (never null) on both backends.

What Happens When Neither Driver Is Available

If neither better-sqlite3 nor node:sqlite can open the file, the first read or write rejects — it never quietly falls back to memory.
In CI that must never silently skip persistence, set PRAISONAI_REQUIRE_SQLITE=1 so a driver-unavailable state becomes a hard failure instead of a soft skip.

Auto-Restore and Caching

Agents restore history and can cache responses automatically:

Best Practices

db('sqlite:./data.db') is the working durable option for praisonai-ts today. Reserve db('memory:') for tests where you want a clean slate every run.
better-sqlite3 is tried first. If you cannot ship a native build, run Node ≥ 22.5 so the built-in node:sqlite driver is available. No driver means a hard reject, not a silent memory fallback.
A file written by the low-level SQLiteAdapter (praisonai/db/sqlite) has a different table shape. Opening it through db('sqlite:…') is diagnosed on open with a clear error — give the durable adapter its own file.
They throw today. Swap only between sqlite: and memory: when changing durability; use the createNeonPostgres / createUpstashRedis factories for those remote transports.

Database CLI

CLI database commands

SqliteDbAdapter Reference

Adapter internals and driver order

Sessions

Conversation persistence

Memory

Agent memory systems