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. Onlysqlite: and memory: are wired to the Agent’s session/message/run contract today.
Database URL Formats
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 neitherbetter-sqlite3 nor node:sqlite can open the file, the first read or write rejects — it never quietly falls back to memory.
Auto-Restore and Caching
Agents restore history and can cache responses automatically:Best Practices
Use sqlite: in production, memory: in tests
Use sqlite: in production, memory: in tests
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.Install better-sqlite3, or run Node ≥ 22.5
Install better-sqlite3, or run Node ≥ 22.5
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.Point sqlite: at its own file
Point sqlite: at its own file
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.Don't assume postgres:// or redis:// work
Don't assume postgres:// or redis:// work
They throw today. Swap only between
sqlite: and memory: when changing durability; use the createNeonPostgres / createUpstashRedis factories for those remote transports.Related
Database CLI
CLI database commands
SqliteDbAdapter Reference
Adapter internals and driver order
Sessions
Conversation persistence
Memory
Agent memory systems

