Гайз помогите
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 7",
app.get('/createtable', async (req, res) => {
const sql = `create table if not exists cars(
id int primary key auto_increment,
date varchar(255) not null,
name varchar(255) not null,
counter int(11) not null,
track varchar(255) not null,
)`;
connection.query(sql, function (err, results) {
if (err) console.log(err);
else console.log('Таблица создана');
});
const cars = [
[
Date.now(), 'Gazelle', 123, '5km'],
[
Date.now(), 'Lada', 70, '15km'],
[
Date.now(), 'Toyota', 15, '65km'],
];
const insert =
INSERT INTO cars(date, name, counter, track) VALUES ?
;
connection.query(insert, [cars], function (err, results) {
if (err) console.log(err);
console.log(results);
});
connection.end();
res.json({ data: cars });
});