{"id":27976,"library":"mysql-database","title":"mysql-database","description":"Easily modify MySQL database data with easy functions. Current stable version is 1.3.2. Provides a simplified API with Promise support and events like connected, dataModification, tableCreate/Delete/Clear/Rename. Methods include set, get, push, pull, add, subtract, exists, clear, delete, and base_set/base_get for encrypted rows. Key differentiator is the event system mirroring library actions. Last updated in 2022, release cadence unknown. Not actively maintained since 2022.","status":"active","version":"1.3.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/1TGDev/mysql-database","tags":["javascript","mysql","mysql db","mysql-db","mysql.db","mysql database","mysql-database","mysql.database","sql database"],"install":[{"cmd":"npm install mysql-database","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-database","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-database","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the underlying MySQL connection","package":"mysql","optional":false}],"imports":[{"note":"Package is CJS, not ESM. Use require() or use dynamic import()","wrong":"import MySQL from 'mysql-database';","symbol":"default","correct":"const MySQL = require('mysql-database');"},{"note":"connect() is async and returns db instance, don't pass config to constructor","wrong":"const db = new MySQL({ host: 'localhost' });","symbol":"instance.connect","correct":"const db = await database.connect({ host: 'localhost', user: 'root', password: '', database: 'test' });"},{"note":"Event emitter is the db instance returned by connect(), not the MySQL constructor","wrong":"database.on('connected', ...)","symbol":"db.on('connected')","correct":"db.on('connected', (connection) => { console.log(connection); });"}],"quickstart":{"code":"const MySQL = require('mysql-database');\nconst database = new MySQL();\n\nasync function main() {\n  const db = await database.connect({\n    host: 'localhost',\n    user: 'root',\n    password: process.env.DB_PASSWORD ?? '',\n    database: 'my_database'\n  });\n\n  db.on('connected', () => console.log('Connected'));\n  await db.set('users', '1', { name: 'Alice', age: 30 });\n  const user = await db.get('users', '1');\n  console.log(user); // { name: 'Alice', age: 30 }\n  await db.end();\n}\nmain().catch(console.error);","lang":"javascript","description":"Connect to MySQL, set and get a key-value pair, then close connection."},"warnings":[{"fix":"Check for null or use exists() before get().","message":"get method returns null if table does not exist (since v1.3.0).","severity":"breaking","affected_versions":">=1.3.0"},{"fix":"Use library methods to modify data if event tracking is needed.","message":"Events are only emitted if action is taken from the library. Manual SQL changes via other clients won't trigger events.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider migrating to 'mysql2' and using a more maintained wrapper like 'typeorm' or 'knex'.","message":"The library has no releases since 2022. The underlying 'mysql' package is also deprecated in favor of 'mysql2'.","severity":"deprecated","affected_versions":"all"},{"fix":"Upgrade to >=1.2.8 or use lowercase table names.","message":"Table names with uppercase letters may cause 'undefined tables' errors before v1.2.8.","severity":"gotcha","affected_versions":"<1.2.8"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Create an instance first: const db = new MySQL(); then db.connect(...).","cause":"Calling connect() on the MySQL constructor instead of an instance.","error":"TypeError: db.connect is not a function"},{"fix":"Create the database manually: CREATE DATABASE my_database;","cause":"Database does not exist. Library does not auto-create databases.","error":"Error: ER_BAD_DB_ERROR: Unknown database 'my_database'"},{"fix":"Ensure MySQL server is running and host/port are correct.","cause":"MySQL server not running or wrong host/port.","error":"Error: connect ECONNREFUSED"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}