{"id":43273,"library":"mysql-easy","title":"mysql-easy","description":"A lightweight promise-based wrapper around the mysql package (version 2.x) that simplifies common database operations like select, insert, update, and delete. Version 0.3.3 is the current stable release; the package has seen no updates for over 5 years and is considered feature-complete. It provides a cleaner API with helper methods for CRUD operations and transaction support, but lacks TypeScript definitions and modern async/await patterns. It is best suited for small to medium projects already using the mysql driver, but for new projects consider more up-to-date alternatives like mysql2 or knex.","status":"maintenance","version":"0.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/Bacher/mysql-easy","tags":["javascript","mysql","promise"],"install":[{"cmd":"npm install mysql-easy","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-easy","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-easy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"runtime peer dependency for actual MySQL protocol handling","package":"mysql","optional":false}],"imports":[{"note":"Package is CommonJS only; no ESM exports available. Use require() in Node.js.","wrong":"import mysqlEasy from 'mysql-easy';","symbol":"mysql-easy (default)","correct":"const mysqlEasy = require('mysql-easy');"},{"note":"createPool is the typical starting point for connection pooling; createConnection also exists but is rarely used.","wrong":"const db = mysqlEasy.createConnection({...});","symbol":"createPool","correct":"const db = mysqlEasy.createPool({...});"},{"note":"Always use parameterized queries to avoid SQL injection; the library does not support raw string interpolation.","wrong":"db.query('SELECT * FROM users WHERE id = 12').then(results => ...);","symbol":"query method","correct":"db.query('SELECT * FROM users WHERE id = ?', [12]).then(results => ...).catch(err => ...);"},{"note":"The result object from insert has insertId, not id.","wrong":"db.insert('users', { user_name: 'foo', age: 30 }).then(result => console.log(result.id));","symbol":"insert method","correct":"db.insert('users', { user_name: 'foo', age: 30 }).then(result => console.log(result.insertId));"},{"note":"select takes a single object parameter, not separate arguments.","wrong":"db.select('users', { id: 12 }).then(rows => ...);","symbol":"select","correct":"db.select({ table: 'users', where: { id: 12 } }).then(rows => ...);"}],"quickstart":{"code":"const mysqlEasy = require('mysql-easy');\nconst db = mysqlEasy.createPool({\n  host: process.env.DB_HOST || 'localhost',\n  database: process.env.DB_NAME || 'test',\n  user: process.env.DB_USER || 'root',\n  password: process.env.DB_PASS || ''\n});\n\n// Insert a user\ndb.insert('users', { name: 'John', age: 30 })\n  .then(result => console.log('Inserted ID:', result.insertId))\n  .catch(err => console.error(err));\n\n// Select users\ndb.select({ table: 'users', where: { age: 30 } })\n  .then(rows => console.log(rows))\n  .catch(err => console.error(err));\n\n// Close pool\ndb.end();","lang":"javascript","description":"Creates a connection pool, inserts a row, selects rows by condition, and closes the pool using CommonJS require."},"warnings":[{"fix":"Update code to use .then() or async/await with createTransaction().","message":"Version 0.3.x changed the API for transaction handling; createTransaction() now returns a promise instead of accepting a callback.","severity":"breaking","affected_versions":"0.3.0"},{"fix":"Consider migrating to mysql2 or an alternative wrapper like promise-mysql.","message":"The mysql package (peer dependency) has deprecated the old callback-based API in favor of mysql2. mysql-easy does not support mysql2 and may break with future mysql versions.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Use an array of strings for fields to avoid confusion; the object syntax maps field names to result properties.","message":"When using select() with a 'fields' option as an object, field names are used as property names in the result, not as aliases.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Always provide a where condition to avoid accidental mass deletion.","message":"delete() and deleteFrom() are aliases; both expect an object or string for the where clause. Omitting where will delete all rows.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Wrap your queries in a retry loop or use a connection pool with built-in recovery.","message":"The library does not handle connection disconnections or reconnections automatically; you must implement retry logic if needed.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Switch to mysql2 which is actively maintained and provides better security.","message":"The mysql package (peer dep) last released in 2018; it has several open CVEs related to SQL injection and authentication.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"search_vec":"'0.3.3':29 '2':15 '5':43 'alreadi':82 'altern':97 'api':55 'around':10 'async/await':71 'base':8 'best':75 'cleaner':54 'common':19 'complet':50 'consid':47,91 'crud':60 'current':32 'databas':20 'date':96 'definit':68 'delet':27 'driver':86 'easi':3 'featur':49 'feature-complet':48 'helper':57 'insert':24 'javascript':102 'knex':101 'lack':66 'lightweight':5 'like':22,98 'medium':80 'method':58 'modern':70 'mysql':2,12,85,103 'mysql-easi':1 'mysql2':99 'new':89 'oper':21,61 'packag':13,36 'pattern':72 'project':81,90 'promis':7,104 'promise-bas':6 'provid':52 'releas':34 'seen':38 'select':23 'simplifi':18 'small':78 'stabl':33 'suit':76 'support':64 'transact':63 'typescript':67 'up-to-d':93 'updat':25,40 'use':83 'version':14,28 'wrapper':9 'x':16 'year':44","created_at":"2026-06-05T16:59:00.793982+00:00","updated_at":"2026-06-05T16:59:00.793982+00:00","problems":[{"fix":"Run: npm install mysql","cause":"Missing required peer dependency mysql.","error":"Error: Cannot find module 'mysql'"},{"fix":"Use const mysqlEasy = require('mysql-easy'); instead of import.","cause":"Incorrect import; trying to use ESM default import with a CommonJS module.","error":"TypeError: mysqlEasy.createPool is not a function"},{"fix":"Ensure query() is called with a string SQL and optional array of params. Check that db is a valid connection/pool.","cause":"Query method called with wrong arguments returning undefined or callback-based result.","error":"TypeError: db.query(...).then is not a function"},{"fix":"Verify host, user, password, and database in the connection config.","cause":"Invalid database credentials or missing privileges.","error":"Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'"}],"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":"https://github.com/Bacher/mysql-easy#readme","github":"https://github.com/Bacher/mysql-easy","docs":null,"changelog":null,"pypi":null,"npm":"mysql-easy","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}}