Registry / database / k8w-promise-mysql

k8w-promise-mysql

JSON →
library1.4.1jsnpmunverified

A simple native Promise wrapper for mysqljs/mysql (the popular MySQL client for Node.js). Version 1.4.1 is current; release cadence is irregular. It mirrors the mysqljs/mysql API exactly but returns Promises instead of using callbacks, enabling async/await usage. Key differentiators: lightweight (no dependencies beyond mysql), TypeScript types included, and supports pool and connection queries. It does not add any extra features over the original library, only converts callback patterns to promises.

npm install k8w-promise-mysql
INSTALL
IMPORT
SIG · K8W-PROMISE-MYSQL
K
k8w-promise-mysql
databasejavascriptv1.4.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.

default
import PromiseMySQL from 'k8w-promise-mysql'
const PromiseMySQL = require('k8w-promise-mysql')
The package exports a default class. CommonJS require will work but TypeScript may complain; use named import if needed.
ConnectionConfig
import type { ConnectionConfig } from 'k8w-promise-mysql'
Type-only import for configuration objects; available as a named export for TypeScript users.
QueryResult
import type { QueryResult } from 'k8w-promise-mysql'
Type for the result of query/select; includes fields and results.

Shows creating a connection pool, executing a simple query and a parameterized query, then closing the pool.

import PromiseMySQL from 'k8w-promise-mysql'; async function main() { const pool = await PromiseMySQL.createPool({ connectionLimit: 10, host: 'example.org', user: 'bob', password: 'secret', database: 'my_db' }); const { results, fields } = await pool.query('SELECT 1 + 1 AS solution'); console.log(results); // [ { solution: 2 } ] const { results: r2, fields: f2 } = await pool.query('SELECT * FROM test WHERE a=? AND b=?', ['aaa', 'bbb']); await pool.end(); } main().catch(console.error);
Debug
Known issues
gotchaThe library wraps mysqljs/mysql but does not add transaction or connection management beyond the original.
fix
Use pool.getConnection() for manual transaction control, same as mysqljs/mysql documentation.
affects: all
gotchaResults and fields are returned as a destructured object, not as an array like mysql2/promise.
fix
Always destructure: const { results, fields } = await pool.query(...);
affects: all
gotchaThe library does not support ES modules natively; it uses CommonJS and default export.
fix
Use dynamic import or a bundler that handles CJS interop.
affects: all
Errors
Common errors & fixes
TypeError: PromiseMySQL.createPool is not a function
Incorrect import; likely using named import instead of default import.
fix
Use import PromiseMySQL from 'k8w-promise-mysql' instead of import { createPool } from 'k8w-promise-mysql'.
Cannot find module 'k8w-promise-mysql'
Missing dependency; mysqljs/mysql is a peer dependency and must be installed separately.
fix
Run: npm install mysql
Property 'query' does not exist on type 'Pool'
TypeScript not recognizing the wrapper types; may need to install @types/mysql or declare module.
fix
Ensure mysql is installed (types are bundled with k8w-promise-mysql) and restart TypeScript server.
Upgrade
Version history
1.4.1latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency; k8w-promise-mysql wraps mysqljs/mysql and requires it at runtime.
Agent activity
7 hits · last 30 days
node
6
Resources
k8w-promise-mysql — npm install k8w-promise-mysql · libregistry