Registry / database / mysql-as-promised

mysql-as-promised

JSON →
library0.2.2jsnpmunverified

mysql-as-promised is a lightweight wrapper around the popular mysql npm package that returns promises instead of using callbacks, enabling async/await syntax. Version 0.2.2 is the latest stable release; development appears to have stopped and the API is incomplete. It differentiates by avoiding external promise libraries (using native ES6 promises) and preserving the original mysql API shape, but only covers a subset of mysql operations.

npm install mysql-as-promised
INSTALL
IMPORT
SIG · MYSQL-AS-PROMISED
M
mysql-as-promised
databasejavascriptv0.2.2
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.

default
import mysql from 'mysql-as-promised'
const mysql = require('mysql-as-promised')
Package does not assign to module.exports; default import is the only correct ESM pattern. CommonJS require may work but is not officially supported.
createPool
import { createPool } from 'mysql-as-promised'
const mysql = require('mysql-as-promised'); mysql.createPool
Named export available; avoid mixing default and named exports with CommonJS.
createConnection
import { createConnection } from 'mysql-as-promised'
Named export for direct connections.

Creates a connection pool, queries using async/await, and releases resources.

import mysql from 'mysql-as-promised'; async function main() { const pool = mysql.createPool('mysql://test@localhost/test'); const connection = await pool.getConnection(); const rows = await connection.query('SELECT ? + ? AS solution', [2, 3]); console.log(rows[0].solution); // => 5 connection.release(); await pool.end(); } main().catch(console.error);
Debug
Known issues
deprecatedThe package appears to be unmaintained (last commit years ago). Do not use in new projects.
fix
Consider using mysql2/promise or knex for production.
affects: >=0.0.0
gotchaOnly a subset of mysql API is implemented; missing features like multiple statements, streaming, etc.
fix
Check source or test coverage before adopting.
affects: >=0.0.0
gotchaPackage uses native Promise (ES6). Node.js versions < 0.12 may not have native Promise support.
fix
Use Node >= 4 or provide a polyfill.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'mysql'
mysql is a peer dependency and not installed automatically.
fix
npm install mysql
TypeError: mysql.createPool is not a function
Improper import: using default import when function is not exported.
fix
Use default import: import mysql from 'mysql-as-promised'
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency; the wrapper requires the mysql package to function.
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-as-promised — npm install mysql-as-promised · libregistry