MCPcopy
hub / github.com/benborla/mcp-server-mysql / getPool

Function getPool

src/db/index.ts:60–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58let poolPromise: Promise<mysql2.Pool>;
59
60const getPool = (): Promise<mysql2.Pool> => {
61 if (!poolPromise) {
62 poolPromise = new Promise<mysql2.Pool>((resolve, reject) => {
63 try {
64 const pool = mysql2.createPool(config.mysql);
65 log("info", "MySQL pool created successfully");
66 resolve(pool);
67 } catch (error) {
68 log("error", "Error creating MySQL pool:", error);
69 reject(error);
70 }
71 });
72 }
73 return poolPromise;
74};
75
76async function executeQuery<T>(sql: string, params: string[] = []): Promise<T> {
77 let connection;

Callers 4

createMcpServerFunction · 0.85
executeQueryFunction · 0.85
executeWriteQueryFunction · 0.85
executeReadOnlyQueryFunction · 0.85

Calls 1

logFunction · 0.50

Tested by

no test coverage detected