Files
ClassContent/历届学生/王凯/11-16/src/mysql.js
2024-09-27 02:06:13 +08:00

29 lines
812 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const mysql = require('mysql');
// 第一步 配置数据库连接
var pool = mysql.createPool({
host : 'localhost',
user : 'root',
password : 'lb714500',
database : 'shop'
});
// 连接数据库
// connection.connect();
// 第二部 配置查询数据库
var sql = "INSERT INTO shop_commodity(commodity_name) VALUES('大米科技')"
var params = ['4']
pool.query(sql,params, function (error, results, fields) {
if (error) throw error;
console.log(results);
});
// 目标实现一个小说爬虫
// 1: gulp 进行文件监听使用babel转换es6代码为es5js代码压缩
// 2: mysql数据库存储爬到的数据
// 3: 使用nodejs的web框架 express(koa2) 并改造
// 4: 使用nodejs nodemailer 向我们自己发送邮件,提示小说有没有更新,到底更新几章