Install
openclaw skills install sqliteUse SQLite correctly with proper concurrency, pragmas, and type handling.
openclaw skills install sqlitePRAGMA journal_mode=WAL—allows reads during writes, huge improvementPRAGMA busy_timeout=5000—waits 5s before SQLITE_BUSY instead of failing immediately-wal and -shm files—don't forget to copy them with main databaseBEGIN IMMEDIATE to grab write lock early—prevents deadlocks in read-then-write patternsPRAGMA foreign_keys=ON required per connection—not persisted in databasePRAGMA foreign_keys returns 0 or 1STRICT tables enforce types—but only SQLite 3.37+ (2021)ALTER TABLE very limited—can add column, rename table/column; that's mostly itALTER TABLE ADD COLUMN can't have PRIMARY KEY, UNIQUE, or NOT NULL without defaultPRAGMA optimize before closing long-running connections—updates query planner statsPRAGMA cache_size=-64000 for 64MB cache—negative = KB; default very smallPRAGMA synchronous=NORMAL with WAL—good balance of safety and speedPRAGMA temp_store=MEMORY for temp tables in RAM—faster sorts and temp resultsVACUUM rewrites entire database, reclaims spaceVACUUM needs 2x disk space temporarily—ensure enough roomPRAGMA auto_vacuum=INCREMENTAL with PRAGMA incremental_vacuum—partial reclaim without full rewrite.backup command in sqlite3—or sqlite3_backup_* API-wal and -shm must be copied atomically with main fileVACUUM INTO 'backup.db' creates standalone copy (3.27+)CREATE INDEX ... WHERE conditionCREATE INDEX ON t(lower(name))EXPLAIN QUERY PLAN shows index usage—simpler than PostgreSQL EXPLAINBEGIN; INSERT...; INSERT...; COMMIT—10-100x fasterBEGIN EXCLUSIVE for exclusive lock—blocks all other connectionsSAVEPOINT name / RELEASE name / ROLLBACK TO nameVACUUM can change ROWIDs; use explicit INTEGER PRIMARY KEY':memory:'—each connection gets different database; use file::memory:?cache=shared for shared