Answer the question
In order to leave comments, you need to log in
How to insert many rows into postgresql table at once?
It is necessary to insert in one request from 10 rows.
I insert one line like this:
pg.Query('INSERT INTO items (item, source, views, date_add, last_view, short_link, category, price, sale_price) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)', [data.item, data.source, data.views, data.date_add, data.last_view, data.short_link, data.category, data.price, data.sale_price]);
Query: function (sql, values, singleItem) {
return new Promise((resolve, reject) => {
try {
pool.query(sql, values, function (err, result) {
if (err) {
reject(err);
} else {
// console.log('Результат: ', result)
resolve(singleItem ? result.rows[0] : result);
}
});
}
catch (e) {
reject(e);
}
});
},
INSERT INTO person (name, age) VALUES
('john doe', 25),
('jane doe', 20);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question