Registry / database / tframe-mysql

tframe-mysql

JSON →
library8.1.20jsnpmunverified

MySQL handler for smpoo tFrame ecosystem, built on Sequelize. Current version 8.1.20, maintained by smpoo team. Provides database check, ORM-based table initialization, SQL execution, and event-driven lifecycle. Tightly coupled with tframe-utility for configuration and events. Differentiated by integration with smpoo tFrame microservices framework. Release cadence irregular, primarily fixing bugs. v8.0.3 and below migrated to tframe-orms.

npm install tframe-mysql
INSTALL
IMPORT
SIG · TFRAME-MYSQL
T
tframe-mysql
databasejavascriptv8.1.20
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.

default
const MysqlEg = require('tframe-mysql');
import MysqlEg from 'tframe-mysql';
Package uses CommonJS exports. ESM import may not work.
MysqlEg
const { MysqlEg } = require('tframe-mysql');
Default export is the constructor, not named export. Named export does not exist.
MysqlEg (instance methods)
const mysqlEg = new MysqlEg(option);
Must pass option processed by tframe-utility.

Shows initialization of MysqlEg with tframe-utility option and execution of a simple SQL query with event handling.

const tFrameUtility = require('tframe-utility'); const MysqlEg = require('tframe-mysql'); const option = tFrameUtility.getMysqlOption({ host: process.env.MYSQL_HOST || 'localhost', port: parseInt(process.env.MYSQL_PORT || '3306'), user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '', database: process.env.MYSQL_DATABASE || 'test' }); const mysqlEg = new MysqlEg(option); mysqlEg.onEvent('initOk', () => { console.log('DB init successful'); }); mysqlEg.onEvent('initErr', (err) => { console.error('DB init failed:', err); }); mysqlEg.init().then(() => { return mysqlEg.dbExec('SELECT 1+1 AS result'); }).then(([results]) => { console.log(results); }).catch(err => { console.error(err); });
Debug
Known issues
deprecatedVersions <=8.0.3 have been migrated to tframe-orms package.
fix
Use tframe-orms package instead.
affects: <=8.0.3
gotchaOption parameter must be processed via tframe-utility.getMysqlOption() — raw Sequelize config may cause errors.
fix
Require('tframe-utility') and call getMysqlOption() before passing to constructor.
affects: >=8.0.4
gotchaEvent names must match exactly with tframe-utility enum (e.g., 'initOk', 'initErr', 'sqlOk', etc).
fix
Reference event names from tframe-utility's event enum.
affects: >=8.0.4
gotchadbCheck and init methods may fail if database does not exist — they do not create the database automatically.
fix
Ensure MySQL database is created before calling dbCheck/init.
affects: >=8.0.4
breakingSwitched from custom ORM to Sequelize in v8.1.0, breaking API compatibility.
fix
Use Sequelize query format; old dbExec parameters may need adjustment.
affects: >=8.1.0
Errors
Common errors & fixes
TypeError: MysqlEg is not a constructor
Using ESM import syntax with CommonJS package
fix
Use require('tframe-mysql') instead of import.
Error: option.host is required
Option object passed without tframe-utility processing
fix
Wrap config with tFrameUtility.getMysqlOption() before constructing MysqlEg.
SequelizeConnectionError: Unknown database 'your_db'
Database not created on MySQL server
fix
Create database manually or use a migration tool before dbCheck/init.
Upgrade
Version history
8.1.20latest on npm
Audit
Dependencies
tframe-utilityrequiredProvides option processing and event enums
sequelizerequiredORM for MySQL operations
mysql2requiredMySQL driver for Sequelize
Agent activity
19 hits · last 30 days
node
16
Meta
1
OpenAI (training)
1
Resources
tframe-mysql — npm install tframe-mysql · libregistry