MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / BetterSqliteAdapter

Class BetterSqliteAdapter

packages/node-runtime/src/better-sqlite3-adapter.ts:38–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 * 基于 better-sqlite3 的 DatabaseAdapter 实现
37 */
38export class BetterSqliteAdapter implements DatabaseAdapter {
39 readonly?: boolean
40
41 constructor(private db: Database.Database) {
42 this.readonly = db.readonly
43 }
44
45 exec(sql: string): void {
46 this.db.exec(sql)
47 }
48
49 prepare(sql: string): PreparedStatement {
50 return new BetterSqlitePreparedStatement(this.db.prepare(sql))
51 }
52
53 transaction<T>(fn: () => T): T {
54 return this.db.transaction(fn)()
55 }
56
57 pragma(pragma: string): unknown {
58 return this.db.pragma(pragma)
59 }
60
61 close(): void {
62 this.db.close()
63 }
64}
65
66/**
67 * 从文件路径打开数据库并返回适配器

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected