Registry / database / express-mysql-pool

express-mysql-pool

JSON →
library1.0.3jsnpmunverified

Express middleware that provides MySQL connection pooling, automatically attaching a connection to each request and releasing it on response end. Version 1.0.3 (latest, no recent updates). Simple wrapper around mysql module's pool; focuses on request-scoped connections. Alternatives: express-mysql-connection (individual connections), mysql2/promise pool (modern).

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Package is CommonJS; use require or default import with ESM interop.

import myConn from 'express-mysql-pool'

In CommonJS, require returns the function directly, not an object with default property.

const myConn = require('express-mysql-pool')

getConnection is callback-based, not Promise-based. No promise version available.

req.getConnection(function(err, conn) { ... })

Sets up Express middleware to attach MySQL pool connection to each request, queries a table, returns JSON.

var mysql = require('mysql'); var myConn = require('express-mysql-pool'); var express = require('express'); var app = express(); var dbOptions = { host: 'localhost', user: process.env.DB_USER || 'root', password: process.env.DB_PASS || '', database: 'test' }; app.use(myConn(mysql, dbOptions)); app.get('/api/foods', function(req, res, next) { req.getConnection(function(err, conn) { if(err) return next(err); conn.query('SELECT * FROM food', function(err, results) { if(err) return next(err); res.json(results); }); }); }); app.listen(3000);
Debug
Known footguns
breakingUses old callback style. No Promise or async/await support.
gotchaRequires mysql module as first argument; passing wrong module (e.g., mysql2) may not work correctly.
deprecatedThe 'mysql' package itself is in maintenance mode; consider migrating to mysql2.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
mj12bot
1
ahrefsbot
1
Resources