{"id":43338,"library":"mysql-query-util","title":"mysql-query-util","description":"A lightweight MySQL utility for Node.js that simplifies CRUD operations with a declarative, non-SQL-like syntax. Version 1.1.1 provides an abstraction over raw MySQL queries for select, insert, update, and delete operations. It uses a connection pool for efficient database management. Known for its simplicity, it is suitable for small to medium projects but lacks advanced features like migrations, query building, or TypeScript support. Alternative to knex or mysql2/promise.","status":"active","version":"1.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/uchennaemeruche/mysql-util","tags":["javascript","npm","node","mysql","crud","express","insert","procedure"],"install":[{"cmd":"npm install mysql-query-util","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-query-util","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-query-util","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for MySQL database connectivity","package":"mysql","optional":false}],"imports":[{"note":"CJS only; does not support ESM imports.","wrong":"import mysqlUtil from 'mysql-query-util';","symbol":"default (mysqlUtil)","correct":"const mysqlUtil = require('mysql-query-util');"}],"quickstart":{"code":"const mysqlUtil = require('mysql-query-util');\n\nmysqlUtil.setConnection({\n    host: process.env.DB_HOST ?? 'localhost',\n    user: process.env.DB_USER ?? 'root',\n    password: process.env.DB_PASSWORD ?? '',\n    database: process.env.DB_NAME ?? 'test',\n    connectionLimit: 25\n});\n\nasync function main() {\n    const result = await mysqlUtil.select('users');\n    console.log(result);\n}\nmain();","lang":"javascript","description":"Initializes a MySQL connection pool and performs a select query on the 'users' table using async/await."},"warnings":[{"fix":"Use async/await or promise chaining.","message":"All methods return a promise; must be awaited or .then() used.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Call mysqlUtil.setConnection with valid config at startup.","message":"setConnection must be called before any other method, otherwise throws 'Connection not initialized'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure each condition array is exactly 3 or 4 elements: [field, operator, value] or ['AND'/'OR', field, operator, value].","message":"Parameters passed as arrays with inline operators: e.g., ['gender', 'like', 'female']. Incorrect ordering or missing operator leads to bad queries.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade to >=1.0.0 and use setConnection with pool options.","message":"Version 1.x uses connection pool; older versions (0.x) used single connection and different initialization.","severity":"breaking","affected_versions":"<=1.0.0"}],"env_vars":null,"search_vec":"'1.1.1':24 'abstract':27 'advanc':62 'altern':71 'build':67 'connect':42 'crud':13,80 'databas':46 'declar':17 'delet':37 'effici':45 'express':81 'featur':63 'insert':34,82 'javascript':76 'knex':73 'known':48 'lack':61 'lightweight':6 'like':21,64 'manag':47 'medium':58 'migrat':65 'mysql':2,7,30,79 'mysql-query-util':1 'mysql2/promise':75 'node':78 'node.js':10 'non':19 'non-sql-lik':18 'npm':77 'oper':14,38 'pool':43 'procedur':83 'project':59 'provid':25 'queri':3,31,66 'raw':29 'select':33 'simplic':51 'simplifi':12 'small':56 'sql':20 'suitabl':54 'support':70 'syntax':22 'typescript':69 'updat':35 'use':40 'util':4,8 'version':23","created_at":"2026-06-05T16:59:19.154550+00:00","updated_at":"2026-06-05T16:59:19.154550+00:00","problems":[{"fix":"Use require('mysql-query-util') and install package via npm.","cause":"Incorrect import style (ESM import) or package not installed.","error":"TypeError: mysqlUtil.select is not a function"},{"fix":"Invoke mysqlUtil.setConnection({...}) at startup.","cause":"setConnection not called before making queries.","error":"Error: Connection not initialized"},{"fix":"Ensure mysqlUtil calls are awaited in async route handlers.","cause":"Calling mysqlUtil methods without awaiting, causing multiple responses in Express.","error":"Error: Can't set headers after they are sent."}],"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/uchennaemeruche/mysql-util#readme","github":"https://github.com/uchennaemeruche/mysql-util","docs":null,"changelog":null,"pypi":null,"npm":"mysql-query-util","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}}