MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / openDatabase

Function openDatabase

src/utils/sqlite.ts:8–21  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

6const connections = new Map<string, Database.Database>();
7
8export function openDatabase(filePath: string): Database.Database {
9 if (connections.has(filePath)) {
10 return connections.get(filePath)!;
11 }
12 const dir = path.dirname(filePath);
13 fs.mkdirSync(dir, { recursive: true });
14 const db = new Database(filePath);
15 db.pragma('journal_mode = WAL');
16 db.pragma('foreign_keys = ON');
17 db.pragma('synchronous = NORMAL');
18 db.pragma('busy_timeout = 5000');
19 connections.set(filePath, db);
20 return db;
21}
22
23export function closeAll(): void {
24 for (const db of connections.values()) {

Callers 4

constructorMethod · 0.85
constructorMethod · 0.85
constructorMethod · 0.85
constructorMethod · 0.85

Calls 3

hasMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected