MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / createDatabase

Function createDatabase

src/db/sqlite-adapter.ts:199–214  ·  view source on GitHub ↗
(dbPath: string, opts?: { readOnly?: boolean })

Source from the content-addressed store, hash-verified

197 * a process-global would race.
198 */
199export function createDatabase(dbPath: string, opts?: { readOnly?: boolean }): { db: SqliteDatabase; backend: SqliteBackend } {
200 try {
201 return { db: new NodeSqliteAdapter(dbPath, opts), backend: 'node-sqlite' };
202 } catch (error) {
203 // node:sqlite loaded and SQLite itself failed — not a missing-module case.
204 const shared = toWslSharedIndexError(error, dbPath);
205 if (shared) throw shared;
206 const msg = error instanceof Error ? error.message : String(error);
207 throw new Error(
208 'Failed to open SQLite via the built-in node:sqlite module.\n' +
209 'CodeGraph requires node:sqlite (Node.js 22.5+). Install the self-contained\n' +
210 'CodeGraph release (it bundles a compatible Node), or run on Node 22.5+.\n' +
211 `Underlying error: ${msg}`
212 );
213 }
214}

Callers 13

store-worker.tsFile · 0.90
resolver-worker.tsFile · 0.90
constructorMethod · 0.90
initializeMethod · 0.90
openMethod · 0.90
graphSnapshotFunction · 0.90
makeLegacyDbFunction · 0.90
edgeSetFunction · 0.90
withDbFunction · 0.90
readEdgesFunction · 0.90

Calls 1

toWslSharedIndexErrorFunction · 0.90

Tested by 6

graphSnapshotFunction · 0.72
makeLegacyDbFunction · 0.72
edgeSetFunction · 0.72
withDbFunction · 0.72
readEdgesFunction · 0.72
assertStructuralFunction · 0.72