MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / executeRawSQL

Function executeRawSQL

apps/desktop/main/worker/query/sql.ts:58–77  ·  view source on GitHub ↗
(sessionId: string, sql: string)

Source from the content-addressed store, hash-verified

56 * Returns columnar format with timing for the legacy IPC contract.
57 */
58export function executeRawSQL(sessionId: string, sql: string): SQLResult {
59 const adapter = ensureAdapter(sessionId)
60
61 try {
62 const result = executeSql(adapter, sql, { columnar: true, timing: true, maxRows: 0 })
63 return {
64 columns: result.columns,
65 rows: result.rows as unknown[][],
66 rowCount: result.rowCount,
67 duration: result.duration ?? 0,
68 limited: result.truncated,
69 }
70 } catch (error) {
71 if (error instanceof Error) {
72 const message = error.message.replace(/^SQLITE_ERROR: /, '').replace(/^SQLITE_READONLY: /, '')
73 throw new Error(message)
74 }
75 throw error
76 }
77}

Callers 1

dbWorker.tsFile · 0.90

Calls 2

executeSqlFunction · 0.90
ensureAdapterFunction · 0.85

Tested by

no test coverage detected