A simple Node.js module for calling stored procedures using MySQL.
Install the package using npm:
npm install mysqlprocedures
#Usage
const StoredProcedureCaller = require('mysqlprocedures');
// Set up MySQL connection configuration
const dbConfig = {
host: 'your-host',
user: 'your-username',
password: 'your-password',
database: 'your-database',
};
// Create an instance of StoredProcedureCaller
const storedProcedureCaller = new StoredProcedureCaller(dbConfig);
// Define the stored procedure name and input parameters
const procedureName = 'your_stored_procedure';
const inputs = [param1, param2, param3]; // replace with your actual parameters
// Call the stored procedure
storedProcedureCaller.callStoredProcedure(procedureName, inputs, (error, results) => {
if (error) {
console.error('Error:', error);
} else {
console.log('Results:', results);
}
// Close the MySQL connection
storedProcedureCaller.closeConnection();
});