main.js 852 Bytes
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){});

}