Registry / database / then-mysql

then-mysql

JSON →
library1.1.1jsnpmunverified

A promise-based wrapper for the MySQL driver that provides connection pooling and a nicer API. Version 1.1.1 (latest) is stable but unmaintained since 2015. It converts callback-style mysql queries to promises using a custom thenable pattern, making it incompatible with modern async/await and ES6 Promises. It is a legacy alternative to mysql2 with promise support or knex.

npm install then-mysql
INSTALL
IMPORT
SIG · THEN-MYSQL
T
then-mysql
databasejavascriptv1.1.1
harness data pending
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.

MySql
var MySql = require('then-mysql');
import MySql from 'then-mysql';
This package is CommonJS only and does not support ESM imports.

Creates a connection pool and runs a simple query using the promised-based API.

var MySql = require('then-mysql'); var pool = new MySql({ host: 'localhost', user: 'me', password: 'secret' }); pool.query('SELECT 1 + 1 AS solution') .done(function (result) { console.log(result[0].solution); // 2 pool.dispose().done(); });
Debug
Known issues
deprecatedthen-mysql uses a custom thenable pattern that is not compatible with native Promises or async/await.
fix
Switch to a modern library like mysql2 with promise support, or use knex.
affects: >=0.0.0
gotchaThe package requires the mysql npm package as a peer dependency but does not list it in package.json. You must install mysql separately.
fix
Run `npm install mysql` alongside then-mysql.
affects: >=0.0.0
gotchaThe .done() method must be called on promises to trigger execution; forgetting it will cause queries to never execute.
fix
Always chain .done() or switch to native promises that execute automatically.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: pool.query(...).done is not a function
Forgetting to call .done() or using native Promise methods like .then() instead of .done().
fix
Use .done() instead of .then() to execute the query.
Error: Cannot find module 'mysql'
The mysql peer dependency is not installed.
fix
Run `npm install mysql`.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency: then-mysql wraps the mysql npm package. Must be installed separately.
Agent activity
19 hits · last 30 days
node
16
Meta
2
OpenAI (training)
1
Resources
then-mysql — npm install then-mysql · libregistry