1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

添加sql导入脚本生成工具

This commit is contained in:
2022-10-26 20:44:07 +08:00
parent 66d5f89b02
commit 19e69f9bfd
3 changed files with 50 additions and 31 deletions

View File

@@ -0,0 +1,26 @@
const absPath = `D:/sql_export`;
// 数字转成字符串,同时在前面填充
function fill(num, fillers, length) {
var result = `${num}`;
if (result.length < length)
result = new Array(length - result.length + 1).join(fillers) + result;
return result;
}
// 使用 mysql 导入数据表
let outputArr = [
[
`@echo off`, `D:`, `cd D:/Program/Development/Environment/phpstudy_pro/Extensions/MySQL8.0.12/bin`,
`mysql -hlocalhost -uroot -proot neteasemusic`
].join('\n'),
`use neteasemusic;`
];
let firstIndex = 0;
let lastIndex = 115;
for (let i = firstIndex; i <= lastIndex; i++) {
outputArr.push(`source ${absPath}/comment/comment_${fill(i, '0', 4)}.sql`);
}
outputArr.push("echo done.");
console.log(outputArr.join('\n'));