MCPcopy Create free account
hub / github.com/antvis/AVA / initDb

Method initDb

src/analysis/sqlite.ts:21–38  ·  view source on GitHub ↗

* Initialize the database (lazy loading)

()

Source from the content-addressed store, hash-verified

19 * Initialize the database (lazy loading)
20 */
21 private async initDb(): Promise<void> {
22 if (this.db) return;
23
24 // Check if we're in a browser environment
25 if (typeof window !== 'undefined') {
26 throw new Error('SQLite is not supported in browser environments. Please reduce data size or use in-memory processing.');
27 }
28
29 try {
30 // Dynamic import for Node.js-only module
31 const Database = (await import('better-sqlite3')).default;
32 this.db = new Database(this.dbPath);
33 } catch (error) {
34 throw new Error(
35 `Failed to load better-sqlite3. This module is only available in Node.js environments: ${error instanceof Error ? error.message : String(error)}`
36 );
37 }
38 }
39
40 /**
41 * Load data into SQLite table

Callers 3

loadDataMethod · 0.95
queryMethod · 0.95
getSchemaMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected