| 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) { |