A lightweight MySQL wrapper for Node.js that provides a simplified API for common database operations including query, insert, update, and unique ID generation. Version 1.0.4 is current, with no recent updates or breaking changes. The library wraps the mysql package and adds connection resilience with automatic reconnection attempts. It is designed for small to medium projects where simplicity is preferred over full-featured ORMs like Sequelize or Knex. The API is promise-based and supports async/await. The package is stable but lightly maintained.
npm install led-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a connection, execute a query with parameters, insert a record, and close the connection. Uses CommonJS require.
Use parameterized queries as shown in examples to prevent SQL injection. Avoid string concatenation.
Always call db.close() after finishing database operations, especially in long-running scripts.
Consider using mysql2-based wrappers like mysql2 or knex for better performance and features.
Reuse the same db instance across your application instead of calling dbConnection multiple times.
Run 'npm install led-mysql' and ensure the require path is correct: 'led-mysql' (no leading ./).
Use const dbConnection = require('led-mysql');Create a connection object first: const db = dbConnection(config); then use db.query().
Ensure the property names in the data object correspond exactly to column names in the table.