Registry / database / database-js-mysql

database-js-mysql

JSON →
library1.1.3jsnpmunverified

database-js-mysql is a wrapper for the `mysql` package, primarily designed to integrate MySQL functionality into applications using the `database-js` abstraction layer. It provides a promise-based API for handling MySQL connections and executing queries, offering both standalone usage and integration with the `database-js` Connection class. As of its latest stable version, 1.1.3, released over seven years ago, the package relies on CommonJS modules and older JavaScript syntax. Its key differentiator was providing a consistent `database-js` interface for MySQL, including support for parameterized queries and streamlined connection management, which was useful for abstracting database interactions in its ecosystem.

npm install database-js-mysql
INSTALL
IMPORT
SIG · DATABASE-JS-MYSQL
D
database-js-mysql
databasejavascriptv1.1.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

mysql
✓ var mysql = require('database-js-mysql');
✗ import mysql from 'database-js-mysql';
This package exclusively uses CommonJS modules (`require`). Native ES Modules (`import`) are not supported due to the project's age.
Connection
✓ var Database = require('database-js').Connection;
✗ import { Connection as Database } from 'database-js';
The `Connection` class is provided by the `database-js` package itself, not `database-js-mysql`. Ensure `database-js` is installed.
mysql.open
✓ let connection = mysql.open({...});
In standalone mode, the `open` static method on the `mysql` object (from `database-js-mysql`) is used to establish a connection.

This quickstart demonstrates how to establish a standalone MySQL connection using `database-js-mysql` and execute a simple query. It uses environment variables for sensitive credentials and handles connection opening, querying, and closing with async/await.

const mysql = require('database-js-mysql'); (async () => { let connection, rows; try { connection = mysql.open({ Hostname: process.env.DB_HOST ?? 'localhost', Port: parseInt(process.env.DB_PORT ?? '3306', 10), Username: process.env.DB_USERNAME ?? 'my_secret_username', Password: process.env.DB_PASSWORD ?? 'my_secret_password', Database: process.env.DB_DATABASE ?? 'my_top_secret_database' }); // Ensure the connection is established before querying rows = await connection.query("SELECT * FROM tablea WHERE user_name = 'not_so_secret_user'"); console.log('Query result:', rows); } catch (error) { console.error('Database operation failed:', error); } finally { if (connection) { await connection.close(); console.log('Connection closed.'); } } })();
Debug
Known issues
breakingThe project appears to be abandoned, with no updates or commits in over seven years. This means it is unlikely to support modern Node.js versions, fix security vulnerabilities, or adopt new JavaScript features (e.g., native ESM).
fix
Consider migrating to actively maintained database drivers like `mysql2` or newer ORMs/query builders.
affects: >=1.1.3
gotchaThis package is CommonJS-only and does not support native ES Modules (`import`/`export`). Attempting to `import` from it will result in errors.
fix
Use `require()` syntax for all imports from this package and ensure your project configuration is set up for CommonJS.
affects: >=1.0.0
gotchaThe underlying `mysql` package (version ~2.10.x at the time of this wrapper's last update) may have known vulnerabilities or compatibility issues with modern MySQL server versions or Node.js runtimes. These issues will not be patched by `database-js-mysql`.
fix
Audit the `mysql` dependency for known CVEs. For new projects, prefer `mysql2` which is actively maintained and supports promises and modern features.
affects: >=1.0.0
gotchaSSL configuration requires file paths (e.g., `ssl[ca]`) to be correctly specified and readable by the Node.js process. Incorrect paths or permissions will lead to connection failures that can be difficult to debug.
fix
Ensure that the paths provided for `ssl[ca]`, `ssl[key]`, and `ssl[cert]` are absolute, correct, and that the Node.js process has read permissions for these files. Test SSL connectivity thoroughly.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: Must use import to load ES Module
Attempting to import `database-js-mysql` using `import` statement in an ES Module context.
fix
Change your import statement to `const mysql = require('database-js-mysql');` and ensure your project is configured for CommonJS, or use a tool like Webpack/Rollup to transpile.
Error: connect ECONNREFUSED
The MySQL server is not running, is configured to listen on a different port/host, or firewall rules are blocking the connection.
fix
Verify that the MySQL server is running, check the `Hostname`, `Port`, `Username`, and `Password` in your connection options, and ensure no firewalls are preventing access.
ER_ACCESS_DENIED_ERROR: Access denied for user '...'@'localhost' (using password: YES/NO)
Incorrect username or password provided in the connection options, or the user lacks necessary permissions for the database.
fix
Double-check your `Username` and `Password` in the connection object. Ensure the MySQL user has privileges to connect from the specified host and access the target database.
TypeError: connection.query is not a function
This error often occurs if `mysql.open()` was not `await`ed or if the `connection` object somehow became `undefined` or not the expected promise-wrapped connection.
fix
Ensure `let connection = await mysql.open({...});` is used to properly resolve the promise and get the connection object before calling methods on it.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver for database operations.
database-jsoptionalCore abstraction layer for integrated use, optional for standalone mode.
Agent activity
8 hits · last 30 days
node
8
Resources
database-js-mysql — npm install database-js-mysql · libregistry