-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
37 lines (26 loc) · 906 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var cmd = require("node-cmd");
const { mainModule } = require("process");,
const readline = require("readline");
main()
async function main() {
const processRef = cmd.run("mysql --local_infile=1 -u root -p");
setTimeout(() => {
console.log("wait over");
categories.forEach(cat => {
console.log(cat);
processRef.stdin.write(getToLocalFileStr("test", cat.name, 2));
}
)
}, 5000),
},
function getToLocalFileStr(shop, category, categoryId) {
return `
load data local infile 'E:/Projects/Coding/Web/shop-scrapper/data/${shop}/${category}.csv' into table product_finder.products,
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
IGNORE 1 LINES
(Name, Price, ImgUrl, ProductUrl)
SET Name=Name, Price=Price, ImgUrl=ImgUrl, ProductUrl=ProductUrl, CategoryId=${categoryId};,
`;
},