Utility layer for Kysely on SQLite databases. Use when working with SQLite via Kysely for: schema definition and auto-migration, soft-delete patterns, precompiled queries, pagination, nested transactions using savepoints, SQLite pragma utilities (integrity check, foreign keys, optimization), serialization/deserialization, enhanced logging. Also use when user asks about kysely-sqlite-builder library usage, table definitions, syncDB, generateMigrateSQL, parseExistSchema, or any related functionality.
This skill provides guidance for working with the kysely-sqlite-builder library, a utility layer on top of Kysely for SQLite databases.
npm install kysely-sqlite-builder
Peer dependency: kysely@>=0.28
import Database from 'better-sqlite3'
import { SqliteDialect } from 'kysely'
import { SqliteBuilder } from 'kysely-sqlite-builder'
import { column, defineTable, InferDatabase, useSchema } from 'kysely-sqlite-builder/schema'
const myTable = defineTable({
columns: {
id: column.increments(),
name: column.string({ notNull: true }),
},
primary: 'id',
createAt: true,
updateAt: true,
})
const schema = { myTable }
type DB = InferDatabase<typeof schema>
const builder = new SqliteBuilder<DB>({
dialect: new SqliteDialect({ database: new Database(':memory:') }),
onQuery: true,
})
await builder.syncDB(useSchema(schema, { log: true }))
defineTable with column.* factories to define tablessyncDB(useSchema(schema, options))createAt, updateAt, softDelete, withoutRowIdSoftDeleteSqliteBuilder for automatic soft‑delete filteringdeleteFrom sets isDeleted = 1 (configurable column name)whereExists / whereDeleted to explicitly include/exclude soft‑deleted rowsprecompile<T>() for parameterized query reuse.build(callback) to create reusable compiled queryusing statement (ES2022)pageQuery(queryBuilder, { num, size, queryTotal }) for offset‑based paginationbuilder.transaction() calls automatically use SAVEPOINTSqliteBuilder and SoftDeleteSqliteBuildercheckIntegrity(db) – verify database integrityforeignKeys(db, enable) – enable/disable foreign key constraintsgetOrSetDBVersion(db, version?) – get/set user_versionoptimizePragma(db, options) – set optimization pragmas (cache size, journal mode, etc.)optimizeSize(db, rebuild?) – shrink database filekysely-plugin-serialize (included)createAt/updateAt/softDeleteimport { generateMigrateSQL } from 'kysely-sqlite-builder/schema'
const sqlStatements = await generateMigrateSQL(db, schema, options)
import { parseExistSchema } from 'kysely-sqlite-builder/schema'
const existing = await parseExistSchema(db.kysely)
import { createCodeProvider, useMigrator } from 'kysely-sqlite-builder/migrator'
const provider = createCodeProvider({ ... })
await builder.syncDB(useMigrator(provider, options))
Works with:
SqliteDialect (better‑sqlite3)SqliteWorkerDialect (worker threads)NodeWasmDialect (node‑sqlite3‑wasm)WaSqliteWorkerDialect (browser + IndexedDB/OPFS)IntegrityError thrown when integrity check failsonSuccess and onError hooksFor smaller bundles, consider the external kysely-unplugin-sqlite plugin:
import { plugin } from 'kysely-unplugin-sqlite'
// Use with your bundler (Vite, Webpack, Rollup, etc.)
SchemaSyncOptionsInferDatabase<typeof schema> for type safetykysely-plugin-serializeSAVEPOINT; ensure your SQLite version supports itjournal_mode='WAL', synchronous='NORMAL', etc.)excludeTablePrefix (default sqlite_%) and truncateIfExists options.compile() is called with same parameter shapedeleteColumnName option (default 'isDeleted')npx skills add subframe7536/kysely-sqlite 构建器下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer