Registry / database / mysql-i

mysql-i

JSON →
library4.1.4jsnpmunverified

A promise-based MySQL interface built on top of the mysql package. Version 4.1.4 provides a simple API for common database operations including insert, update, delete, replace, save, select, pagination, transactions, connection pooling, and stored procedures. It supports multiple databases with easy switching, encapsulated transactions, and both sequential and concurrent execution modes for batch operations. The library offers TypeScript type definitions and is suitable for Node.js applications requiring a lightweight, easy-to-use MySQL client without complex ORM features. However, it has limited community adoption and documentation primarily in Chinese, which may pose a barrier for English-speaking developers.

npm install mysql-i
INSTALL
IMPORT
SIG · MYSQL-I
M
mysql-i
databasejavascriptv4.1.4
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.

mysql-i
import * as mysqli from 'mysql-i'
const mysqli = require('mysql-i')
The library is primarily CommonJS-based; ESM import works with bundlers or Node.js >=12 with esModuleInterop.
ConnectionHelper
import { ConnectionHelper } from 'mysql-i'
const { ConnectionHelper } = require('mysql-i')
Named exports are available; require destructuring is also valid in CommonJS.
Save
import { Save } from 'mysql-i'
import Save from 'mysql-i'
Save is a named export, not a default export.
Exec
import { Exec } from 'mysql-i'
const exec = require('mysql-i').exec
Exec is capitalized as a class/namespace; the lowercase 'exec' might be confused with the method.

Demonstrates creating a MySQL connection, executing raw SQL, inserting and deleting a row using the Save helper, with proper error handling and connection cleanup.

import { ConnectionHelper, Exec, Save, SaveType } from 'mysql-i'; async function run() { let conn; try { conn = await ConnectionHelper.create({ host: 'localhost', user: 'root', password: process.env.MYSQL_PASSWORD || '', database: 'test', port: 3306 }); await Exec.exec(conn, `create table if not exists tbl_test (id int not null primary key, value varchar(255))` ); await Save.save(conn, { data: { id: 1, value: 'hello' }, table: 'tbl_test', saveType: SaveType.insert }); const result = await Save.save(conn, { data: { id: 1 }, table: 'tbl_test', saveType: SaveType.delete }); console.log(result); } catch (err) { console.error(err); } finally { await ConnectionHelper.close(conn); } } run();
Debug
Known issues
deprecatedThe 'require' style imports may not work with strict ESM environments.
fix
Use import statements or enable esModuleInterop in tsconfig.
affects: >=4.0.0
gotchaSave.save with SaveType.update requires a primary key in the data object; otherwise it may update all rows.
fix
Always include the primary key field in the data object for update operations.
affects: *
Errors
Common errors & fixes
Cannot find module 'mysql'
mysql peer dependency not installed.
fix
Run 'npm install mysql' in your project.
ConnectionHelper.create is not a function
Incorrect import: using default import instead of named import.
fix
Use 'import { ConnectionHelper } from 'mysql-i'' instead of 'import ConnectionHelper from 'mysql-i''.
Upgrade
Version history
4.1.4latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver used for database connection and query execution
Agent activity
4 hits · last 30 days
node
4
Resources
mysql-i — npm install mysql-i · libregistry