Skip to content

alex-fournier/execsql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

execsql

An npm project. Node.js Execute your *.sql files which contain multiple sql statements.

Usage

As a CLI tool

  1. Make sure you have execsql installed globally

    npm install -g execsql
  2. Configure your db access for the first time. Usage: execsql -c host [port] user password.

    # default port is 3306
    execsql -c "localhost" "root" "root"
    # when using a custom port like 4242
    execsql -c "localhost" 4242 "root" "root"
  • Execute a bunch of sql statements

     execsql "use db_cam; delete from admin;"
  • Execute a .sql file

     execsql -f ./db.sql

As a Node dependency

  1. Make sure you have execsql installed locally

    npm install execsql
  2. Require and use

    var execsql = require('execsql'),
    	dbConfig = {
    		host: 'localhost',
    		port: 3306, // optional, default is 3306
    		user: 'root',
    		password: 'root'
    	},
    	sql = 'use db_cam;',
    	sqlFile = __dirname + '/db.sql';
    
    execsql.config(dbConfig)
    	.exec(sql)
    	.execFile(sqlFile, function (err, results) {
    		if (err) throw err;
    		console.log(results);
    	})
    	.end();

About

An npm project. Node.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%