main.js
852 Bytes
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
38
39
const mysql = require("mysql");
const swuniv = require('./silte_modules/swuniv.js')
async function loading(){
li = await swuniv.loading();
for(var i = 0; i < li.length;i++){
await insertNotice(li[i]);
}
}
loading();
var connection = mysql.createConnection({
host: "34.64.183.182",
user: 'root',
password: '',
database: 'KhuNotice'
})
connection.connect();
connection.query('select * from noticeList',function(err,rows){
if(err){
console.log(err);
}
console.log(rows);
})
async function insertNotice(singleNotice){
date = singleNotice.date;
title = singleNotice.title;
link = singleNotice.link;
site = singleNotice.site;
await connection.query(`insert into noticeList (date, title, link, site) values('${date}','${title}','${link}','${site}')`,function(err){});
}