MCPcopy
hub / github.com/colbymchenry/codegraph / configureConnection

Function configureConnection

src/db/index.ts:30–38  ·  view source on GitHub ↗

* Apply connection-level PRAGMAs. Shared by `initialize` and `open` so the two * paths can't drift. * * `busy_timeout` is set FIRST, before any pragma that might touch the database * file (notably `journal_mode`). If another process holds a write lock at open * time, the later pragmas — and the

(db: SqliteDatabase)

Source from the content-addressed store, hash-verified

28 * (e.g. the git-hook `codegraph sync` running while the MCP server writes).
29 */
30function configureConnection(db: SqliteDatabase): void {
31 db.pragma('busy_timeout = 5000'); // MUST be first — see above
32 db.pragma('foreign_keys = ON');
33 db.pragma('journal_mode = WAL'); // node:sqlite supports WAL on every platform
34 db.pragma('synchronous = NORMAL'); // safe with WAL mode
35 db.pragma('cache_size = -64000'); // 64 MB page cache
36 db.pragma('temp_store = MEMORY'); // temp tables in memory
37 db.pragma('mmap_size = 268435456'); // 256 MB memory-mapped I/O
38}
39
40/**
41 * Database connection wrapper with lifecycle management

Callers 2

initializeMethod · 0.85
openMethod · 0.85

Calls 1

pragmaMethod · 0.65

Tested by

no test coverage detected