{"id":44555,"library":"chat-adapter-sqlite","title":"chat-adapter-sqlite","description":"SQLite state adapter for Chat SDK built with better-sqlite3. Current stable version: 0.4.0. Release cadence: irregular, based on upstream Chat SDK updates. Key differentiators: lightweight local persistent state without Redis or Postgres, supports subscriptions, locking, caching, lists, and message queueing; automatic table creation and key prefix namespacing; opportunistic cleanup of expired entries. Requires Node >=20.10.0 and peer dependencies better-sqlite3 ^12.6.2 and chat ^4.23.0.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/yjl9903/chat-adapter-qq","tags":["javascript","sqlite","chat","chat-sdk","chat-adapter","typescript"],"install":[{"cmd":"npm install chat-adapter-sqlite","lang":"bash","label":"npm"},{"cmd":"yarn add chat-adapter-sqlite","lang":"bash","label":"yarn"},{"cmd":"pnpm add chat-adapter-sqlite","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for SQLite database operations","package":"better-sqlite3","optional":false},{"reason":"Peer dependency; Chat SDK must be installed","package":"chat","optional":false}],"imports":[{"note":"Package is ESM-only. Named export used.","wrong":"const createSqliteState = require('chat-adapter-sqlite').createSqliteState","symbol":"createSqliteState","correct":"import { createSqliteState } from 'chat-adapter-sqlite'"},{"note":"TypeScript type export; must use type import for runtime safety.","wrong":"import { SqliteStateOptions } from 'chat-adapter-sqlite'","symbol":"SqliteStateOptions","correct":"import type { SqliteStateOptions } from 'chat-adapter-sqlite'"},{"note":"better-sqlite3 is a CommonJS package; default import works with ESM.","wrong":"const Database = require('better-sqlite3')","symbol":"Database (better-sqlite3)","correct":"import Database from 'better-sqlite3'"}],"quickstart":{"code":"import { Chat } from 'chat';\nimport { createSqliteState } from 'chat-adapter-sqlite';\n\nconst bot = new Chat({\n  userName: 'mybot',\n  adapters: {\n    // ...\n  },\n  state: createSqliteState({\n    path: './data/chat-state.db'\n  })\n});\n\nbot.start();","lang":"typescript","description":"Creates a Chat bot with an SQLite state adapter, specifying the database path."},"warnings":[{"fix":"Upgrade Node.js to v20.10.0 or later.","message":"Requires Node >=20.10.0","severity":"breaking","affected_versions":"all"},{"fix":"Explicitly pass path option when creating state adapter.","message":"Automatic database path detection via SQLITE_PATH environment variable may change in future versions.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Call methods like get(), acquireLock() regularly to trigger cleanup, or implement a periodic cleanup mechanism.","message":"Expired rows are not automatically deleted; cleanup only occurs on specific operations.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Redis-based adapter for distributed locking.","message":"SQLite locking is host-local; not suitable for distributed multi-machine locking.","severity":"gotcha","affected_versions":"all"},{"fix":"Set SQLITE_PATH or pass path/client in options.","message":"Must provide either path, SQLITE_PATH environment variable, or a client instance; otherwise createSqliteState() throws.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.4.0':19 '12.6.2':68 '20.10.0':61 '4.23.0':71 'adapt':3,7,80 'automat':47 'base':23 'better':14,66 'better-sqlite3':13,65 'built':11 'cach':42 'cadenc':21 'chat':2,9,26,70,74,76,79 'chat-adapt':78 'chat-adapter-sqlit':1 'chat-sdk':75 'cleanup':55 'creation':49 'current':16 'depend':64 'differenti':30 'entri':58 'expir':57 'irregular':22 'javascript':72 'key':29,51 'lightweight':31 'list':43 'local':32 'lock':41 'messag':45 'namespac':53 'node':60 'opportunist':54 'peer':63 'persist':33 'postgr':38 'prefix':52 'queue':46 'redi':36 'releas':20 'requir':59 'sdk':10,27,77 'sqlite':4,5,73 'sqlite3':15,67 'stabl':17 'state':6,34 'subscript':40 'support':39 'tabl':48 'typescript':81 'updat':28 'upstream':25 'version':18 'without':35","created_at":"2026-06-07T12:50:42.708704+00:00","updated_at":"2026-06-07T12:50:42.708704+00:00","problems":[{"fix":"Pass `{ path: './data/chat.db' }` or set `SQLITE_PATH` environment variable, or provide an existing `better-sqlite3` client.","cause":"Missing required database path or client instance.","error":"Error: No path or client provided to createSqliteState()"},{"fix":"Use `import { createSqliteState } from 'chat-adapter-sqlite'` instead of `require()`.","cause":"Using CommonJS require() incorrectly; package is ESM-only.","error":"TypeError: chat_adapter_sqlite_1.createSqliteState is not a function"},{"fix":"Run `npm install better-sqlite3` or `pnpm add better-sqlite3`.","cause":"Peer dependency better-sqlite3 is not installed.","error":"Error: Cannot find module 'better-sqlite3'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/yjl9903/chat-adapter-qq#readme","github":"https://github.com/yjl9903/chat-adapter-qq","docs":null,"changelog":null,"pypi":null,"npm":"chat-adapter-sqlite","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}