Registry / database / phanx-mysql

phanx-mysql

JSON →
library0.3.16jsnpmunverified

A MySQL database wrapper for Node.js providing async/await promises, TypeScript definitions, and helper methods for insert/update and named parameters. Current stable version is 0.3.16, last updated with Node.js 11.x support. It wraps the mysql npm package and adds a promise-based interface, automatic idle connection closing, and a query formatter that supports both positional (?) and named (:name) parameters. Unlike more modern libraries (e.g., mysql2, knex), it requires manual configuration via a config.json file and is not actively maintained. It is suitable for simple use cases but lacks connection pooling with advanced features, and the API is somewhat unconventional (e.g., accessing results via getters like db.rows).

npm install phanx-mysql
INSTALL
IMPORT
SIG · PHANX-MYSQL
P
phanx-mysql
databasejavascriptv0.3.16
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.

default
✓ import PhanxMysql from 'phanx-mysql'
✗ const PhanxMysql = require('phanx-mysql')
ESM import pattern; the default export is a class. CommonJS require also works but is not recommended for TypeScript projects.
PhanxMysql
✓ import PhanxMysql from 'phanx-mysql'
✗ import { PhanxMysql } from 'phanx-mysql'
The library does not export a named member; the default export is the class itself.
type
✓ import type { PhanxMysqlConfig } from 'phanx-mysql'
✗ import { PhanxMysqlConfig } from 'phanx-mysql'
If you need the config type, use type-only import. The type is not a runtime export.

Shows how to import, configure, create a connection, run a query, and close the connection using async/await.

import PhanxMysql from 'phanx-mysql'; import config from './config.json' with { type: 'json' }; PhanxMysql.config = config; PhanxMysql.setAutoCloseMinutes(1); async function run() { const db = await PhanxMysql.createAndStart(); const rows = await db.query('select * from test;'); if (db.error) console.error(db.error); console.log(rows); await db.end(); } run().catch(console.error);
Debug
Known issues
gotchaUsing require('phanx-mysql') returns the class, not an instance; must call new or use static method createAndStart().
fix
Use 'new PhanxMysql()' and then 'await db.start()' or 'await PhanxMysql.createAndStart()'.
affects: >=0.0.0
deprecatedPackage is no longer actively maintained; last release 0.3.16 from 2019.
fix
Consider migrating to mysql2 or knex for better maintenance and features.
affects: >=0.0.0
gotchaThe config.json file must be present and contain a valid JSON object with connection properties; environment variables are not supported.
fix
Create a config.json file in your project root with properties like host, user, password, database.
affects: >=0.0.0
breakingIn version 0.2.x, the API used callbacks; starting 0.3.0 promises were added but the callback style still works.
fix
Use async/await or .then() for promise-based control flow.
affects: >=0.3.0 <0.4.0
Errors
Common errors & fixes
TypeError: PhanxMysql.config is not configurable
Attempting to set PhanxMysql.config before import or after connection
fix
Set PhanxMysql.config immediately after import, before any async calls.
Error: Cannot find module 'config.json'
Missing config.json file in the working directory
fix
Create a config.json with database connection info in your project root.
TypeError: db.query is not a function
Using db.query before calling db.start() or createAndStart()
fix
Ensure you await db.start() or await PhanxMysql.createAndStart() before calling query.
Upgrade
Version history
0.3.16latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver
Agent activity
9 hits · last 30 days
node
8
Resources
phanx-mysql — npm install phanx-mysql · libregistry