I know exactly the same question was asked, but:
- It was 11 years ago
- Solution from this answer does not handles
execBatch()method withaddBindValue(QVariantList).
Using QVariantList as a parameter is helpful for me, because in my SQL queries I don't create a string like this:
(?, ?, ?), ... , (?, ?, ?)
but instead, I can use only one (?, ?, ?) and add many items by:
query.prepare("insert into a (b, c) values (?, ?)");
query.addBindValue(qvariantlist1);
query.addBindValue(qvariantlist2);
query.execBatch();
Code from 11 yo post only substitutes each ? with only the first element of QVariantList.
How do I get it to replace each ? by all the values of the QVariantList bound to it?
If I understood you correctly, you just need to modify the solution from the question you linked a little bit, add another dimension to it.
Last query before:
Last query after (output of the last
qDebug()):