Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
GenericSqliteDialect
✓ import { GenericSqliteDialect } from 'kysely-generic-sqlite'
✗ const GenericSqliteDialect = require('kysely-generic-sqlite').GenericSqliteDialect
ESM-only. Default export is not provided.
GenericSqliteWorkerDialect
✓ import { GenericSqliteWorkerDialect } from 'kysely-generic-sqlite/worker'
✗ import { GenericSqliteWorkerDialect } from 'kysely-generic-sqlite'
Worker dialect is in a subpath export 'kysely-generic-sqlite/worker'. Importing from main package will not include it.
createNodeWorkerExecutor
✓ import { createNodeWorkerExecutor } from 'kysely-generic-sqlite/worker-helper-node'
✗ import { createNodeWorkerExecutor } from 'kysely-generic-sqlite'
Helper for Node.js worker threads is in subpath 'kysely-generic-sqlite/worker-helper-node'. There is also a non-Node platform helper at 'kysely-generic-sqlite/worker-helper'.
IGenericSqlite
✓ import type { IGenericSqlite } from 'kysely-generic-sqlite'
TypeScript type; only import as type. Do not use at runtime.
parseBigInt
✓ import { parseBigInt } from 'kysely-generic-sqlite'
✗ const parseBigInt = require('kysely-generic-sqlite').parseBigInt
Utility function to parse large integers from SQLite results (number or BigInt).
Initialize a Kysely instance with a SQLite in-memory database using better-sqlite3 and the GenericSqliteDialect.
import Kysely from 'kysely'
import { GenericSqliteDialect } from 'kysely-generic-sqlite'
import Database from 'better-sqlite3'
import type { IGenericSqlite } from 'kysely-generic-sqlite'
const db = new Database(':memory:')
const executor: IGenericSqlite<Database> = {
db,
query: (_isSelect: boolean, sql: string, parameters?: readonly unknown[]) => {
const stmt = db.prepare(sql)
if (stmt.reader) {
return { rows: stmt.all(parameters as any) }
}
const { changes, lastInsertRowid } = stmt.run(parameters as any)
return {
rows: [],
numAffectedRows: BigInt(changes),
insertId: BigInt(lastInsertRowid),
}
},
close: () => db.close(),
iterator: (_isSelect: boolean, sql: string, parameters?: readonly unknown[]) => {
return db.prepare(sql).iterate(parameters as any)
},
}
const dialect = new GenericSqliteDialect(executor)
const kysely = new Kysely<any>({ dialect })
await kysely.schema.createTable('test').addColumn('id', 'integer').execute()
await kysely.insertInto('test').values({ id: 1 }).execute()
const rows = await kysely.selectFrom('test').selectAll().execute()
console.log(rows)
Errors
Common errors & fixes
Cannot find module 'kysely-generic-sqlite/worker'
Attempting to import from 'kysely-generic-sqlite/worker' without using the correct subpath export; possibly trying to import from main package.
fixEnsure you are using a modern bundler or Node.js version that supports package.json exports. Import exactly: import { GenericSqliteWorkerDialect } from 'kysely-generic-sqlite/worker' TypeError: executor.query is not a function
The executor object passed to GenericSqliteDialect does not have a query method or does not conform to IGenericSqlite interface.
fixImplement the IGenericSqlite interface with a query method that returns an object with 'rows' and optionally 'numAffectedRows' and 'insertId'.
error: Unsupported import path: 'kysely-generic-sqlite' does not export 'GenericSqliteWorkerDialect'
Importing GenericSqliteWorkerDialect from the main package instead of the worker subpath.
fixChange import to: import { GenericSqliteWorkerDialect } from 'kysely-generic-sqlite/worker' Audit
Dependencies
kyselyoptionalPeer dependency; the library provides a Kysely dialect and requires Kysely >=0.26 to function.