1.0.2 • Published 8 years ago

install-sql v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

#初始化数据库

把文件里的sql语句导入到数据库

##使用方法

具体看sample文件夹里的例子,写一个install.js文件

'use strict';

let Install = require('install-sql');
let process = require('process');
process.chdir(__dirname);

let dbcfg = require('./dbcfg.js');
//let sqlFiles = './gdata_us.sql';
let sqlFiles = ['./gdata_us.sql','./gdata_us2.sql'];

let install = new Install(dbcfg, sqlFiles);
install.run();

dbcfg.js数据库配置文件

module.exports = {
  host: '192.168.99.100',
  port: '3306',
  database: 'test',
  user: 'root',
  password: 'suckit44',
};

sql文件可以是单独的文件,也可以是多个文件写成数组的形式

let sqlFiles = './gdata_us.sql';
let sqlFiles = ['./gdata_us.sql','./gdata_us2.sql'];

安装一次以后,会在当前module文件夹下生成一个install.lock文件,防止二次安装,如果要重新安装需要删除这个文件。

安装完成以后,最好把install.js文件删除