MCPcopy Create free account
hub / github.com/bytebase/dbhub / connect

Method connect

src/connectors/mysql/index.ts:141–157  ·  view source on GitHub ↗
(dsn: string, initScript?: string, config?: ConnectorConfig)

Source from the content-addressed store, hash-verified

139 }
140
141 async connect(dsn: string, initScript?: string, config?: ConnectorConfig): Promise<void> {
142 try {
143 const connectionOptions = await this.dsnParser.parse(dsn, config);
144 this.pool = mysql.createPool(connectionOptions);
145
146 // Store query timeout for per-query application
147 if (config?.queryTimeoutSeconds !== undefined) {
148 this.queryTimeoutMs = config.queryTimeoutSeconds * 1000;
149 }
150
151 // Test the connection
152 const [rows] = await this.pool.query("SELECT 1");
153 } catch (err) {
154 console.error("Failed to connect to MySQL database:", err);
155 throw err;
156 }
157 }
158
159 async disconnect(): Promise<void> {
160 if (this.pool) {

Callers 1

createSSLTestsMethod · 0.95

Calls 1

parseMethod · 0.65

Tested by 1

createSSLTestsMethod · 0.76