{"id":18662,"library":"phanx-mysql","title":"phanx-mysql","description":"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).","status":"maintenance","version":"0.3.16","language":"javascript","source_language":"en","source_url":"git://github.com/phanxgames/phanx-mysql","tags":["javascript","typescript"],"install":[{"cmd":"npm install phanx-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add phanx-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add phanx-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver","package":"mysql","optional":false}],"imports":[{"note":"ESM import pattern; the default export is a class. CommonJS require also works but is not recommended for TypeScript projects.","wrong":"const PhanxMysql = require('phanx-mysql')","symbol":"default","correct":"import PhanxMysql from 'phanx-mysql'"},{"note":"The library does not export a named member; the default export is the class itself.","wrong":"import { PhanxMysql } from 'phanx-mysql'","symbol":"PhanxMysql","correct":"import PhanxMysql from 'phanx-mysql'"},{"note":"If you need the config type, use type-only import. The type is not a runtime export.","wrong":"import { PhanxMysqlConfig } from 'phanx-mysql'","symbol":"type","correct":"import type { PhanxMysqlConfig } from 'phanx-mysql'"}],"quickstart":{"code":"import PhanxMysql from 'phanx-mysql';\nimport config from './config.json' with { type: 'json' };\n\nPhanxMysql.config = config;\nPhanxMysql.setAutoCloseMinutes(1);\n\nasync function run() {\n  const db = await PhanxMysql.createAndStart();\n  const rows = await db.query('select * from test;');\n  if (db.error) console.error(db.error);\n  console.log(rows);\n  await db.end();\n}\nrun().catch(console.error);","lang":"typescript","description":"Shows how to import, configure, create a connection, run a query, and close the connection using async/await."},"warnings":[{"fix":"Use 'new PhanxMysql()' and then 'await db.start()' or 'await PhanxMysql.createAndStart()'.","message":"Using require('phanx-mysql') returns the class, not an instance; must call new or use static method createAndStart().","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to mysql2 or knex for better maintenance and features.","message":"Package is no longer actively maintained; last release 0.3.16 from 2019.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Create a config.json file in your project root with properties like host, user, password, database.","message":"The config.json file must be present and contain a valid JSON object with connection properties; environment variables are not supported.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use async/await or .then() for promise-based control flow.","message":"In version 0.2.x, the API used callbacks; starting 0.3.0 promises were added but the callback style still works.","severity":"breaking","affected_versions":">=0.3.0 <0.4.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Set PhanxMysql.config immediately after import, before any async calls.","cause":"Attempting to set PhanxMysql.config before import or after connection","error":"TypeError: PhanxMysql.config is not configurable"},{"fix":"Create a config.json with database connection info in your project root.","cause":"Missing config.json file in the working directory","error":"Error: Cannot find module 'config.json'"},{"fix":"Ensure you await db.start() or await PhanxMysql.createAndStart() before calling query.","cause":"Using db.query before calling db.start() or createAndStart()","error":"TypeError: db.query is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}