{"id":43270,"library":"mysql-easier","title":"mysql-easier","description":"A Node.js library (v2.1.0) that provides a simplified interface for MySQL database operations, wrapping the popular mysql package with convenience methods like insert, getById, and deleteById. Supports connection pooling, automatic pool management, or single connections. Last updated in 2023; stable but low-maintenance. Differentiates itself by reducing boilerplate for common CRUD tasks compared to raw mysql usage, but lacks TypeScript types and modern async patterns.","status":"maintenance","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/mvolkmann/mysql-easier","tags":["javascript","Node","MySQL"],"install":[{"cmd":"npm install mysql-easier","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-easier","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-easier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for MySQL database connectivity; mysql-easier wraps mysql Connection and Pool objects.","package":"mysql","optional":false}],"imports":[{"note":"ESM import is recommended for new projects; package.json exports support both. The module exports functions like configure, getConnection, createPool, etc.","wrong":"const mysqlEasier = require('mysql-easier'); // CJS require still works but TypeScript resolution may be incomplete","symbol":"default (module object)","correct":"import mysqlEasier from 'mysql-easier';"},{"note":"Use createPool() method to get a Pool instance.","wrong":"import { Pool } from 'mysql-easier'; // Pool is not a named export; it's internal","symbol":"Pool","correct":"import { Pool } from 'mysql-easier'; // Not exported – use module object instead"},{"note":"Connection instances are returned by getConnection() or createConnection().","wrong":"import { Connection } from 'mysql-easier'; // Not a named export","symbol":"Connection","correct":"import mysqlEasier from 'mysql-easier'; const conn = await mysqlEasier.getConnection();"}],"quickstart":{"code":"import mysqlEasier from 'mysql-easier';\n\n// Configure global pool\nmysqlEasier.configure({\n  host: process.env.DB_HOST ?? 'localhost',\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASS ?? '',\n  database: process.env.DB_NAME ?? 'test'\n});\n\n(async () => {\n  try {\n    const conn = await mysqlEasier.getConnection();\n    const newId = await conn.insert('users', { name: 'Alice', email: 'alice@example.com' });\n    console.log('Inserted ID:', newId);\n\n    const user = await conn.getById('users', newId);\n    console.log('User:', user);\n\n    await conn.deleteById('users', newId);\n    await conn.done();\n    await mysqlEasier.endPool();\n  } catch (err) {\n    console.error('Error:', err);\n  }\n})();","lang":"javascript","description":"Shows how to configure a pool, get a connection, insert a row, retrieve by ID, delete, and release resources."},"warnings":[{"fix":"Always call await conn.done() after finishing database operations, or use a try/finally block.","message":"Connections must be released with done() after use; otherwise pool exhaustion occurs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update code to use conn.insert() instead of mysqlEasier.insert(). See migration guide in README.","message":"In v2.0.0, getConnection() returns a Connection instance instead of a raw mysql connection. Methods like insert(), getById() are now on the Connection object.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use instance methods on Connection objects returned by getConnection() or createConnection().","message":"The global methods insert(), update(), delete(), etc. are deprecated in v2.x and removed in v3.0.0.","severity":"deprecated","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Install @types/mysql for basic type coverage or create a declaration file for mysql-easier.","message":"The library does not provide TypeScript definition files; users must define their own types.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always include the 'database' property in the configuration object passed to configure() or createPool().","message":"The 'database' option is required in the config object; omission will cause a runtime error.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2023':42 'async':68 'automat':33 'boilerpl':52 'common':54 'compar':57 'connect':31,38 'conveni':23 'crud':55 'databas':15 'deletebyid':29 'differenti':48 'easier':3 'getbyid':27 'insert':26 'interfac':12 'javascript':70 'lack':63 'last':39 'librari':6 'like':25 'low':46 'low-mainten':45 'mainten':47 'manag':35 'method':24 'modern':67 'mysql':2,14,20,60,72 'mysql-easi':1 'node':71 'node.js':5 'oper':16 'packag':21 'pattern':69 'pool':32,34 'popular':19 'provid':9 'raw':59 'reduc':51 'simplifi':11 'singl':37 'stabl':43 'support':30 'task':56 'type':65 'typescript':64 'updat':40 'usag':61 'v2.1.0':7 'wrap':17","created_at":"2026-06-05T16:58:59.825796+00:00","updated_at":"2026-06-05T16:58:59.825796+00:00","problems":[{"fix":"Run: npm install mysql","cause":"mysql-easier depends on mysql which must be installed explicitly.","error":"Error: Cannot find module 'mysql'"},{"fix":"Use: const conn = await mysqlEasier.getConnection(); await conn.insert(...);","cause":"In v2.x, insert() is a method on Connection instances, not on the module object (global API deprecated).","error":"TypeError: mysqlEasier.insert is not a function"},{"fix":"Ensure all database operations complete before closing the pool, and do not reuse connections after pool closure.","cause":"Attempting to use a connection after calling endPool() or pool.end().","error":"Error: Pool is closed"}],"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/mvolkmann/mysql-easier#readme","github":"https://github.com/mvolkmann/mysql-easier","docs":null,"changelog":null,"pypi":null,"npm":"mysql-easier","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}}