Registry / database / mql-mysql

mql-mysql

JSON →
library1.0.21jsnpmunverified

A SQL builder library that uses a matrix object (MQL) to dynamically construct MySQL queries. Current stable version is 1.0.21. It allows building SELECT, INSERT, UPDATE, and DELETE queries programmatically using table and column definitions. Depends on the ext-mysql package for database connectivity. Differentiators include a unique matrix-based approach for defining queries and handling joins/relationships. However, the library is niche and has very limited adoption, with minimal documentation and no active development since 2020.

npm install mql-mysql
INSTALL
IMPORT
SIG · MQL-MYSQL
M
mql-mysql
databasejavascriptv1.0.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MQL
const { MQL } = require('mql-mysql')
import { MQL } from 'mql-mysql'
Package uses CommonJS; ESM import may not work without bundler
MQLtoMySQL
const { MQLtoMySQL } = require('mql-mysql')
const MQLtoMySQL = require('mql-mysql')
MQLtoMySQL is a named export, not default
MQL
const MQL = require('mql-mysql').MQL
const MQL = require('mql-mysql')
Requiring the package directly gives an object, not the MQL class

Shows how to create an MQL object, add a table and columns, then execute a SELECT query against MySQL.

const { MQL, MQLtoMySQL } = require('mql-mysql'); const MySQL = require('ext-mysql'); process.env.ENCODE = 'utf8'; process.env.MYSQL_HOSTNAME = 'localhost'; process.env.MYSQL_USER = 'root'; process.env.MYSQL_PASSWORD = process.env.MYSQL_PASSWORD ?? ''; process.env.MYSQL_DATABASE = 'test'; MySQL.CREATE_POOL(); async function run() { const conn = new MySQL(); await conn.init(); const mql = new MQL(); mql.addTable('persons'); mql.persons.addColumn('id'); mql.persons.addColumn('name'); const [rows, fields] = await MQLtoMySQL.select(mql, conn); console.log(rows); conn.release(); } run().catch(console.error);
Debug
Known issues
gotchaEnvironment variables must be set before calling MySQL.CREATE_POOL()
fix
Set ENCODE, MYSQL_HOSTNAME, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE before importing ext-mysql.
affects: >=1.0.0
gotchaMQLtoMySQL methods (select, insert, update, delete) require a second parameter for the connection object; otherwise they might fail silently
fix
Pass the connection as second argument: await MQLtoMySQL.select(mql, conn)
affects: >=1.0.0
gotchaThe library has an implicit dependency on ext-mysql's connection pool; failing to call MySQL.CREATE_POOL() will cause runtime errors
fix
Call MySQL.CREATE_POOL() before any MQLtoMySQL operations.
affects: >=1.0.0
gotchaTable alias must be a valid JavaScript object property; e.g., adding table 'person' creates mql.person
fix
Use mql.addTable('person') then access mql.person. Avoid aliases that are reserved words or cannot be property names.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'addColumn')
Trying to add columns to a table that hasn't been added yet
fix
Ensure table is added first with mql.addTable('tableName') before accessing mql.tableName
Error: Pool is not created
MySQL.CREATE_POOL() was not called before using ext-mysql
fix
Call MySQL.CREATE_POOL() after setting environment variables
ReferenceError: MQLtoMySQL is not defined
Using the package without destructuring the named export
fix
Use const { MQLtoMySQL } = require('mql-mysql')
Upgrade
Version history
1.0.21latest on npm
Audit
Dependencies
ext-mysqlrequiredRequired for database connection and query execution
Agent activity
2 hits · last 30 days
node
2
Resources
mql-mysql — npm install mql-mysql · libregistry