标签:mysq turn func field 连接mysql res export mysql def
const mysql = require(‘mysql‘) const config = require(‘./../../config/config.default‘) var connection = mysql.createConnection({ host: config.database.HOST, user: config.database.USERNAME, password: config.database.PASSWORD, database: config.database.DATABASE }) connection.connect(function(err) { if (err) { console.error(‘error connecting: ‘ + err.stack) return } console.log(‘Database connection successful, connected as id ‘ + connection.threadId) }) //查询 // connection.query(`select * from area`, function(err, results, fields) { // if (err) throw err // console.log(results[0]) // console.log(fields[0]) // }) //关闭连接 // connection.end(function(err) { // if (err) { // console.error(‘数据库关闭失败‘ + err) // } // console.log(‘数据库关闭‘) // }) module.exports = connection
标签:mysq turn func field 连接mysql res export mysql def
原文地址:https://www.cnblogs.com/lfqcode/p/9473861.html