Registry / database / algaeh-mysql

algaeh-mysql

JSON →
library1.5.2jsnpmunverified

A promise-based MySQL connection handling and query execution library designed for internal company use. Version 1.5.2 provides a simple API for executing queries, managing transactions, bulk inserts/updates with key mapping, and automatic connection release. It requires a custom configuration file (default path: keys/keys.js) and wraps mysql2. Not actively maintained for the public; use mysql2 directly for production.

npm install algaeh-mysql
INSTALL
IMPORT
SIG · ALGAEH-MYSQL
A
algaeh-mysql
databasejavascriptv1.5.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.

algaehMysql
import algaehMysql from 'algaeh-mysql'
const algaehMysql = require('algaeh-mysql')
Package is ESM-only. No named exports.
algaehMysql instance
const _mysql = new algaehMysql()
const _mysql = algaehMysql()
Must instantiate with 'new'. Default config reads from keys/keys.js.
executeQuery
_mysql.executeQuery({ query: '...', values: [...] })
_mysql.executeQuery('...')
Accepts an options object, not a raw query string.
executeQueryWithTransaction
_mysql.executeQueryWithTransaction({ query: '...', values: [...] })
_mysql.executeQuery({ query: '...', transaction: true })
Transaction queries use a separate method; no transaction flag on executeQuery.
releaseConnection
_mysql.releaseConnection()
mysql.releaseConnection()
Must be called on the instance after query completion to free the connection.

Connects to MySQL with custom config, runs a parameterized SELECT query, prints the query to console, and releases the connection.

import algaehMysql from 'algaeh-mysql'; const _mysql = new algaehMysql({ path: { mysqlDb: { host: process.env.DB_HOST ?? 'localhost', port: 3306, user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test', multipleStatements: true } } }); _mysql .executeQuery({ query: 'SELECT * FROM users WHERE id = ?', values: [1], printQuery: true }) .then(result => { console.log(result); _mysql.releaseConnection(); }) .catch(error => { console.error(error); _mysql.releaseConnection(); });
Debug
Known issues
gotchaDefault configuration path expects keys/keys.js relative to process.cwd(). If missing, instance will fail silently or throw obscure errors.
fix
Always pass explicit config object or valid file path to constructor.
affects: >=1.0.0
gotchaexecuteQuery and executeQueryWithTransaction must be called on the instance; they are not static methods. Forgetting 'new' will cause 'this is undefined' errors.
fix
Always use 'new algaehMysql()'.
affects: >=1.0.0
gotchaConnections must be released manually after each query or transaction block. Failure to call releaseConnection() will exhaust the connection pool.
fix
Always call _mysql.releaseConnection() in both success and error handlers.
affects: >=1.0.0
breakingPackage does not support CommonJS require(). Attempting to use require() in Node.js will throw 'ERR_REQUIRE_ESM'.
fix
Use ESM imports (import ... from 'algaeh-mysql') or dynamic import() in a CJS project.
affects: >=1.0.0
deprecatedThe internal mysql2 dependency may be outdated. Not actively maintained; no security patches since 2021.
fix
Consider migrating to mysql2 directly for continued support and security updates.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module '../keys/keys.js'
Default config path is relative to CWD but keys/keys.js does not exist.
fix
Pass a config object to the constructor: new algaehMysql({ path: { mysqlDb: {...} } })
TypeError: Cannot read properties of undefined (reading 'executeQuery')
Forgot to instantiate with 'new' or called method on wrong reference.
fix
Ensure you create instance: const _mysql = new algaehMysql()
Error: Connection lost: The server closed the connection.
Connection pool exhausted because releaseConnection() was not called after queries.
fix
Call _mysql.releaseConnection() after each query block, especially in long-running processes.
errno: -4078, code: 'ECONNREFUSED'
MySQL server is not running or host/port are incorrect.
fix
Verify MySQL service status and connection config.
Upgrade
Version history
1.5.2latest on npm
Audit
Dependencies
mysql2requiredUnderlying MySQL driver
Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources
algaeh-mysql — npm install algaeh-mysql · libregistry