execsql
v0.0.3
Published
Execute you *.sql file which contains multiple sql statements. Usate: init database.
Downloads
592
Readme
execsql
An npm project. Node.js Execute you *.sql file which contains multiple sql statements. Usate: init database.
Usage
As a CLI tool
Make sure that you have
execsql
installed globallynpm install -g execsql
Configure your db access for the first time
execsql -c "localhost" "root" "root"
Execute a bunch of sql statements
execsql "use db_cam; delete from admin;"
Execute a
.sql
fileexecsql -f ./db.sql
As a Node dependency
Make sure that you have
execsql
installed locallynpm install execsql
Require and use
var execsql = require('execsql'), dbConfig = { host: 'localhost', user: 'root', password: 'root' }, sql = 'use db_cam;', sqlFile = __dirname + '/db.sql'; execsql.config(dbConfig) .exec(sql) .execFile(sqlFile, function(err, results){ console.log(results); }).end();