{"id":43358,"library":"mysql-singleton","title":"mysql-singleton","description":"A minimal singleton wrapper around the MySQL npm driver that provides a single shared connection pool. Currently at version 1.0.5, last updated in 2018. It offers both callback-based and Promise-based connection retrieval. Differentiators: extremely simple API, but lacks connection management features and is not actively maintained. Consider using mysql2 or knex for production.","status":"deprecated","version":"1.0.5","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","mysql","mysql-singleton","mysql-pool"],"install":[{"cmd":"npm install mysql-singleton","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-singleton","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-singleton","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver used for all database operations","package":"mysql","optional":false}],"imports":[{"note":"Package is CommonJS-only, no ESM support.","wrong":"import mysql_singleton from 'mysql-singleton';","symbol":"mysql_singleton","correct":"const mysql_singleton = require('mysql-singleton');"},{"note":"Config must include 'database' property; missing it will cause runtime errors.","wrong":"mysql_singleton.config({ host: 'localhost', user: 'root' });","symbol":"config","correct":"mysql_singleton.config({host:'localhost',user:'root',password:'',database:'test'});"},{"note":"getConnection does not return a Promise; use getConnectionPromise for async/await.","wrong":"const conn = await mysql_singleton.getConnection();","symbol":"getConnection","correct":"mysql_singleton.getConnection(function(err, connection) { ... });"}],"quickstart":{"code":"const mysql_singleton = require('mysql-singleton');\nconst config = {\n  host: 'localhost',\n  user: 'root',\n  password: '',\n  database: 'test_db'\n};\nmysql_singleton.config(config);\n\nasync function query() {\n  const connection = await mysql_singleton.getConnectionPromise();\n  connection.query('SELECT 1 AS result', (err, results) => {\n    if (err) throw err;\n    console.log(results);\n    connection.release();\n  });\n}\n\nquery().catch(console.error);","lang":"javascript","description":"Shows basic usage: configure the singleton, get a connection asynchronously, run a query, and release the connection."},"warnings":[{"fix":"Migrate to mysql2 or knex for active support and security patches.","message":"Package is unmaintained and relies on the legacy 'mysql' driver, which has known security issues.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use getConnectionPromise for async/await or pass a callback to getConnection.","message":"getConnection does not return a Promise; calling it without a callback will silently fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the config object includes a 'database' property.","message":"Config must include 'database' property; otherwise getConnection will error with 'No database selected'.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.5':23 '2018':27 'activ':52 'api':43 'around':8 'base':33,37 'callback':32 'callback-bas':31 'connect':18,38,46 'consid':54 'current':20 'differenti':40 'driver':12 'extrem':41 'featur':48 'javascript':61 'knex':58 'lack':45 'last':24 'maintain':53 'manag':47 'minim':5 'mysql':2,10,62,64,67 'mysql-pool':66 'mysql-singleton':1,63 'mysql2':56 'npm':11 'offer':29 'pool':19,68 'product':60 'promis':36 'promise-bas':35 'provid':14 'retriev':39 'share':17 'simpl':42 'singl':16 'singleton':3,6,65 'updat':25 'use':55 'version':22 'wrapper':7","created_at":"2026-06-05T16:59:25.024777+00:00","updated_at":"2026-06-05T16:59:25.024777+00:00","problems":[{"fix":"Run 'npm install mysql' as a peer dependency.","cause":"The underlying 'mysql' package is not installed.","error":"Error: Cannot find module 'mysql'"},{"fix":"Ensure the package is installed: 'npm install mysql-singleton' and required correctly.","cause":"The package cannot be found or the import is incorrect.","error":"TypeError: mysql_singleton.getConnection is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"mysql-singleton","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}