我有一个api休息,我从中得到了事件。在我的项目中,我创建一个具有表约会的数据库,然后尝试将我从api接收的表值放入其中。
sqlMessage:'您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册以获取正确的语法,以在\'Alexandru,2019-08-30T10:00:00 + 03:00)\'附近的第1行使用
function listEvents(auth) {
const calendar = google.calendar({version: 'v3', auth});
calendar.events.list({
calendarId: 'primary',
timeMin: (new Date()).toISOString(),
maxResults: 30,
singleEvents: true,
orderBy: 'startTime',
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
const events = res.data.items;
if (events.length) {
console.log('Upcoming 30 events:');
events.map((event, i) => {
const start = event.start.dateTime;
console.log(`${start} - ${event.summary}`);
var sql = "INSERT INTO appointments (id,name,data) VALUES ("+(i+10)+","+event.summary+","+start+");";
db.sequelize.query(sql).then(()=> {
console.log("1 record inserted");
}).catch((err)=>{
console.log(err);
})
});
} else {
console.log('No upcoming events found.');
}
});