{"id":43331,"library":"mysql-qbuilder","title":"mysql-qbuilder","description":"Query builder for MySQL databases in Node.js, providing a fluent interface for constructing SQL queries including SELECT, INSERT, UPDATE, DELETE, JOIN, WHERE conditions, ORDER BY, GROUP BY, LIMIT, and OFFSET. Current stable version is 1.6.1, last updated in 2018. Connects using the mysql module and protects against SQL injection. Key differentiators: simple API, supports chaining, and provides query model methods like add, getFirst, getLast, getAll, findById, findFields. However, the package appears unmaintained with no recent updates, and relies on outdated Node.js engine requirements (>= 6.0.0).","status":"maintenance","version":"1.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/evelikov92/mysql-qbuilder","tags":["javascript","query","query-builder","sql","mysql","builder","mysql-query-builder","mysql-qbuilder"],"install":[{"cmd":"npm install mysql-qbuilder","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-qbuilder","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-qbuilder","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for MySQL connection and query execution.","package":"mysql","optional":false}],"imports":[{"note":"Package uses CommonJS and does not support ES module imports.","wrong":"import qBuilder from 'mysql-qbuilder'","symbol":"default","correct":"const qBuilder = require('mysql-qbuilder')"},{"note":"Options object uses specific keys (hostname, username, password, database). Misnaming keys causes silent failures.","wrong":"qBuilder.setOptions({ host: '...', user: '...', pass: '...', db: '...' })","symbol":"qBuilder.setOptions","correct":"qBuilder.setOptions({ hostname: '...', username: '...', password: '...', database: '...' })"},{"note":"makeQuery() must be called to start a new query chain; methods on qBuilder directly are not available.","wrong":"qBuilder.select('*').from('table')","symbol":"qBuilder.makeQuery","correct":"qBuilder.makeQuery().select('*').from('table')"}],"quickstart":{"code":"const qBuilder = require('mysql-qbuilder');\n\nqBuilder.setOptions({\n  hostname: process.env.DB_HOST ?? 'localhost',\n  username: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASS ?? '',\n  database: process.env.DB_NAME ?? 'test'\n});\n\nqBuilder.connectToDatabase()\n  .then(() => {\n    return qBuilder.makeQuery()\n      .select('id, name, email')\n      .from('users')\n      .where('age', '>', 18)\n      .orderBy('name', 'ASC')\n      .limit(10)\n      .prepare()\n      .getResult();\n  })\n  .then(results => {\n    console.log('Users:', results);\n  })\n  .catch(err => {\n    console.error('Error:', err);\n  });","lang":"javascript","description":"Demonstrates setup with environment variables, connection, query building with select, from, where, orderBy, limit, and execution via prepare().getResult()."},"warnings":[{"fix":"Use Node.js 10+ for compatibility; consider using a maintained query builder like knex.","message":"Node.js engine requirement >= 6.0.0 is outdated; packages relying on newer Node.js features may fail.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Audit dependencies or switch to a maintained alternative. Use npm audit to check for issues.","message":"Package has not been updated since 2018; known vulnerabilities in mysql dependency may exist.","severity":"gotcha","affected_versions":"<=1.6.1"},{"fix":"Use the exact option keys as shown in the documentation: hostname, username, password, database.","message":"qBuilder.setOptions uses property names hostname, username, password, database; not standard mysql connection host, user, password, database.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use .prepare().getResult().then(...) or await qBuilder.prepare().getResult() instead of calling getResult() directly.","message":"In version 1.5.1+, getResult() changed from synchronous to promise-based (via prepare()).","severity":"breaking","affected_versions":">=1.5.1"},{"fix":"Ensure clauses are called in the correct order (e.g., select before from, where before orderBy).","message":"Methods like addSelect, where, and join modify the internal query state; chaining order matters.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.6.1':38 '2018':42 '6.0.0':87 'add':65 'api':56 'appear':74 'builder':5,92,95,99 'chain':58 'condit':26 'connect':43 'construct':16 'current':34 'databas':8 'delet':23 'differenti':54 'engin':85 'findbyid':69 'findfield':70 'fluent':13 'getal':68 'getfirst':66 'getlast':67 'group':29 'howev':71 'includ':19 'inject':52 'insert':21 'interfac':14 'javascript':88 'join':24 'key':53 'last':39 'like':64 'limit':31 'method':63 'model':62 'modul':47 'mysql':2,7,46,94,97,101 'mysql-qbuild':1,100 'mysql-query-build':96 'node.js':10,84 'offset':33 'order':27 'outdat':83 'packag':73 'protect':49 'provid':11,60 'qbuilder':3,102 'queri':4,18,61,89,91,98 'query-build':90 'recent':78 'reli':81 'requir':86 'select':20 'simpl':55 'sql':17,51,93 'stabl':35 'support':57 'unmaintain':75 'updat':22,40,79 'use':44 'version':36","created_at":"2026-06-05T16:59:17.061488+00:00","updated_at":"2026-06-05T16:59:17.061488+00:00","problems":[{"fix":"Update to version >=1.5.1 or if using older version, call .getResult() directly without .prepare().","cause":"Using version <1.5.1 where prepare() did not exist; getResult() was synchronous.","error":"TypeError: qBuilder.makeQuery(...).prepare is not a function"},{"fix":"Call qBuilder.setOptions({...}) with appropriate connection details before connecting.","cause":"setOptions was not called before connectToDatabase, or options object is empty.","error":"Cannot read property 'hostname' of undefined"},{"fix":"Verify hostname, username, password, and database in setOptions. Ensure MySQL server is running.","cause":"Invalid credentials or missing database connection parameters.","error":"Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host' (using password: YES)"},{"fix":"Use const qBuilder = require('mysql-qbuilder') and ensure the module is installed.","cause":"Package not properly required or imported incorrectly.","error":"TypeError: qBuilder.makeQuery 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":"https://github.com/evelikov92/mysql-qbuilder#readme","github":"https://github.com/evelikov92/mysql-qbuilder","docs":null,"changelog":null,"pypi":null,"npm":"mysql-qbuilder","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}}