{"id":42641,"library":"dlovely-mysql","title":"dlovely-mysql","description":"A TypeScript-friendly MySQL query builder and connection manager (v2.2.2) providing a chained API for INSERT, DELETE, UPDATE, SELECT operations with built-in connection pooling, once-off connections, keep-alive connections, and debug/reconnect configuration. Ships TypeScript definitions. Peer dependencies include mysql (^2.18.1) and ts-toolbelt (^9.6.0). Differentiates from knex by being simpler, lightweight, and targeted at quick integration with a minimal API surface. Release cadence appears irregular.","status":"active","version":"2.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/MZ-Dlovely/dlovely-mysql/wiki","tags":["javascript","typescript","mysql","dlovely"],"install":[{"cmd":"npm install dlovely-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add dlovely-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add dlovely-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for MySQL driver connectivity.","package":"mysql","optional":false},{"reason":"Required peer dependency for TypeScript utility types.","package":"ts-toolbelt","optional":false}],"imports":[{"note":"Named export, not default. Also available: MySQLOnce, MySQLKeep, SQL.","wrong":"import MySQLPool from 'dlovely-mysql'","symbol":"MySQLPool","correct":"import { MySQLPool } from 'dlovely-mysql'"},{"note":"ESM module; CommonJS require works but is not recommended.","wrong":"const MySQLOnce = require('dlovely-mysql').MySQLOnce","symbol":"MySQLOnce","correct":"import { MySQLOnce } from 'dlovely-mysql'"},{"note":"Case-sensitive: SQL class for custom queries without built-in connection.","wrong":"import { Sql } from 'dlovely-mysql'","symbol":"SQL","correct":"import { SQL } from 'dlovely-mysql'"},{"note":"Export name is MySQLKeep; keep connection manually.","wrong":"import { MySQLKeepConnection } from 'dlovely-mysql'","symbol":"MySQLKeep","correct":"import { MySQLKeep } from 'dlovely-mysql'"}],"quickstart":{"code":"import { MySQLPool } from 'dlovely-mysql';\n\nconst mysql = MySQLPool({\n  host     : 'localhost',\n  user     : 'my_name',\n  password : 'my_secret',\n  database : 'my_database'\n});\n\nasync function run() {\n  const insertResult = await mysql('users').insert({ name: 'Alice' }).get();\n  console.log('Insert result:', insertResult);\n\n  const selectResult = await mysql('users').select().where({ id: 1 }).get<{ id: number; name: string }>();\n  console.log('Select result:', selectResult);\n}\n\nrun().catch(console.error);","lang":"typescript","description":"Shows how to create a pool connection, perform an INSERT and a SELECT with WHERE, using TypeScript generics."},"warnings":[{"fix":"Run npm install mysql ts-toolbelt","message":"The module requires peerDependencies mysql@^2.18.1 and ts-toolbelt@^9.6.0; not installing them will cause runtime errors or TypeScript compilation failures.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use MySQLPool instead.","message":"MySQLOnce and MySQLKeep are deprecated in favor of MySQLPool for production use.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use MySQLPool(options) instead of new MySQLPool(options).","message":"Version 2.0.0 changed the API from a class-based to a functional factory pattern. Direct use of 'new MySQLPool()' no longer works.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use await mysql('table').insert({col: 'val'}).get()","message":"The .get() method must be awaited; forgetting await returns a Promise object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use .get<{id: number; name: string}>() which returns an array.","message":"TypeScript generic .get<T>() parameter is the row type, not the array type. Return type is T[] for SELECT.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Pass options as separate argument: MySQLPool(dbConfig, { debugger: true })","message":"Debug mode is enabled via the second argument as an object { debugger: true }, not the first argument.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use MySQLOnce with maxReconnectTime if reconnection is needed.","message":"maxReconnectTime option is available only for MySQLOnce, not for MySQLPool.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.18.1':49 '9.6.0':54 'aliv':37 'api':18,70 'appear':74 'builder':10 'built':27 'built-in':26 'cadenc':73 'chain':17 'configur':41 'connect':12,29,34,38 'debug/reconnect':40 'definit':44 'delet':21 'depend':46 'differenti':55 'dlove':2,79 'dlovely-mysql':1 'friend':7 'includ':47 'insert':20 'integr':66 'irregular':75 'javascript':76 'keep':36 'keep-al':35 'knex':57 'lightweight':61 'manag':13 'minim':69 'mysql':3,8,48,78 'once-off':31 'oper':24 'peer':45 'pool':30 'provid':15 'queri':9 'quick':65 'releas':72 'select':23 'ship':42 'simpler':60 'surfac':71 'target':63 'toolbelt':53 'ts':52 'ts-toolbelt':51 'typescript':6,43,77 'typescript-friend':5 'updat':22 'v2.2.2':14","created_at":"2026-06-05T16:55:58.072021+00:00","updated_at":"2026-06-05T16:55:58.072021+00:00","problems":[{"fix":"Run 'npm install dlovely-mysql mysql ts-toolbelt' and ensure tsconfig.json includes 'moduleResolution': 'node'.","cause":"Missing peer dependency installation or incorrect import path.","error":"Cannot find module 'dlovely-mysql' or its corresponding type declarations."},{"fix":"Use mysql('tablename').insert() instead of mysql.insert()","cause":"Using MySQLPool or MySQLOnce incorrectly (missing table name).","error":"Property 'insert' does not exist on type '...'"},{"fix":"Use MySQLPool(config, { debugger: true }) not MySQLPool(config, true)","cause":"Passing database config and debug config as separate arguments to MySQLPool - it expects a single options object or two arguments (config, proxy).","error":"Expected 0-1 arguments, but got 2"},{"fix":"Do not use generics on insert/delete/update; they return OkPacket.","cause":"Calling .get<T>() on a non-SELECT query (e.g., insert).","error":"Type 'OkPacket' is not generic"},{"fix":"Use 'import { SQL } from 'dlovely-mysql';' and not 'import type { SQL } ...'","cause":"Importing SQL as a type instead of a class.","error":"Cannot use namespace 'SQL' as a type"}],"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/MZ-Dlovely/dlovely-mysql/wiki","github":"https://github.com/MZ-Dlovely/dlovely-mysql/wiki","docs":null,"changelog":null,"pypi":null,"npm":"dlovely-mysql","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}}