Registry / database / lupdo-mysql

lupdo-mysql

JSON →
library2.0.0jsnpmunverified

Lupdo-mysql is a MySQL/MariaDB driver for the Lupdo database abstraction layer. Version 2.0.0 requires Node >=18.0.0 and peer dependency lupdo ^4.0.1. It wraps mysql2 internally providing typed TypeScript support, named/numeric placeholders, and a custom type parser that converts boolean to number, bigint to number or BigInt, geometry to JSON string, and all other types to string. Key differentiators: force UTC timezone, default charset UTF8MB4_UNICODE_CI, support for host:port lists, and row-as-array mode. It does NOT support array parameters and ignores TypeBinding type definitions.

npm install lupdo-mysql
INSTALL
IMPORT
SIG · LUPDO-MYSQL
L
lupdo-mysql
databasejavascriptv2.0.0
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.

createMysqlPdo
import { createMysqlPdo } from 'lupdo-mysql'
const createMysqlPdo = require('lupdo-mysql')
TypeScript/ESM default import pattern; CommonJS use createMysqlPdo as named export (not default).
createMysqlPdo
const { createMysqlPdo } = require('lupdo-mysql')
const createMysqlPdo = require('lupdo-mysql').default
CJS destructures named export – avoid .default.
type CreateMysqlPdoOptions
import type { CreateMysqlPdoOptions } from 'lupdo-mysql'
import { CreateMysqlPdoOptions } from 'lupdo-mysql'
Type-only import prevents runtime value usage; Available since v2.

Shows how to create a PDO with connection config and pool sizing, execute a parameterized query, and safely disconnect.

import { createMysqlPdo } from 'lupdo-mysql'; const pdo = createMysqlPdo( { host: process.env.MYSQL_HOST ?? 'localhost', port: Number(process.env.MYSQL_PORT) || 3306, user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test', }, { min: 2, max: 5 } ); (async () => { try { const stmt = await pdo.query('SELECT ? AS result', [42]); const rows = stmt.fetchArray().all(); console.log(rows); // [[42]] } finally { await pdo.disconnect(); } })();
Debug
Known issues
gotchaArray parameters are NOT supported – use scalar values only. Passing an array will cause unexpected behavior or errors.
fix
Bind parameters individually (e.g., multiple ? placeholders) instead of passing an array.
affects: >=1.0.0
gotchaTypeBinding definitions are ignored – all binding types are inferred as string/number/Buffer. Using type-safe binding objects will have no effect.
fix
Do not rely on Lupdo's TypeBinding types; pass plain values.
affects: >=1.0.0
gotchaCasting to boolean is not supported; boolean values are returned as number 1 or 0.
fix
Check for 1/0 instead of true/false when reading results.
affects: >=1.0.0
gotchaZerofill numbers are returned as strings, not numbers. Arithmetic on these may produce unexpected results if not converted.
fix
Parse zerofill strings to Number or BigInt before arithmetic.
affects: >=1.0.0
gotchaGeometry columns are returned as JSON strings (e.g., '{"type":"Point","coordinates":[1,2]}'). Not as objects.
fix
Use JSON.parse() to convert geometry strings into objects if needed.
affects: >=1.0.0
breakingNode.js <18 is no longer supported. Package will fail to install or run on older Node versions.
fix
Upgrade Node.js to >=18.0.0.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'lupdo-mysql'
Package not installed or peer dependency lupdo missing.
fix
Run 'npm install lupdo-mysql lupdo' (lupdo is a peer dependency).
TypeError: createMysqlPdo is not a constructor
Using require('lupdo-mysql') without destructuring the named export.
fix
Use 'const { createMysqlPdo } = require('lupdo-mysql')'.
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL 8 uses caching_sha2_password by default; mysql2 may need legacy auth.
fix
Set 'authPlugins' option or ALTER USER to mysql_native_password.
TypeError: Cannot read properties of undefined (reading 'fetchArray')
pdo.query() returned undefined due to query failure or misconfigured pool.
fix
Check connection config and ensure query returns rows; add error handling.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
lupdorequiredPeer dependency – required as the core database abstraction layer
Agent activity
2 hits · last 30 days
node
2
Resources