Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

mysql-procedure-map

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-procedure-map

Maps a mysql database and generates a code file for all procedures in a given database

latest
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

mysql-procedure-map

Automatically generate a script file housing all of the procedures in a given MySQL Database.

  • Connects to MySQL
  • Discovers a list of procedures and their parameters
  • Generates an output script detailing all the procedures in the database

Setup a connection to the MySQL Database


    const MySQL = require("mysql-procedure-map");

    const db = new MySQL.Database({
        host    : 'localhost',
        user    : 'user',
        password: 'password',
        database: 'my_database'
    });

Generate a procedure map source file.

Javascript

    //Create the database connection as detailed above.
    //Call generateProcedureMapFile with the output filename and callback function.
    db.generateJavascriptFile("./procedures.js",function(err){
        if(err){
            console.error(err);
            return;
        }
        console.log('procedures.js generated from the MySQL Database');
    });

Typescript

    //Create the database connection as detailed above.
    //Call generateProcedureMapFile with the output filename and callback function.
    db.generateTypescriptFile("./procedures.ts",function(err){
        if(err){
            console.error(err);
            return;
        }
        console.log('procedures.ts generated from the MySQL Database');
    });

Calling mapped procedures

    //Require the generate script file.
    const Database = require("./procedures.js");

    //Create a new instance of the pre-generated script - Create the database connection as detailed above and pass it into new Procedures(database).
    const procedures = new Database.Procedures(db);

    //Call the on of the pre-generated procedures.
    procedures.sp_select_users(1,2,'hello',(err, tables, parameters)=>{
        if(err){
             console.error(`Error: ${err.message}`);
            return;
        }
        console.log(`Tables: ${tables.length}`);
        console.log(`Parameters: ${parameters}`);
    });

FAQs

Package last updated on 13 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts