在我创建的mysql表中,我为主键设置了autoincrement和唯一值。它是 我多次运行以下代码。假定大多数情况下由于输入重复的键而显示错误,但是没有错误。
exports.handler = async (event) => {
var mysql = require('mysql');
// TODO implement
var connection = mysql.createConnection({
host : '-',
user : '-',
password : '-',
database : '-'
});
const sql = `INSERT INTO forms VALUES(20,2,4,4,5,6,7,8,9,10,11);`;
connection.query(sql, (err, res) => {
if (err) {
throw err
}
})
const wait = () => {
setTimeout(()=>console.log('timeout'),2000)
}
await wait();
await console.log(sql)
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};