Hi,
Are you planning to implement that feature in the future?
It's already done by QxOrm library if you pass a list of elements to
qx::dao::insert() or
qx::dao::update() functions (see below for supported list types).
For example, you can write something like this :
- Code: Select all
QList<myClass> myList = ...;
QSqlError daoError = qx::dao::insert(myList);
There is only 1 prepare sql query call and then insert all elements to database (see the file
./inl/QxDao/QxDao_Insert.inl, struct
QxDao_Insert_Container for more details about the process).
Moreover, a transaction is automatically created before executing the batch if you don't pass any connection to database (
pDatabase parameter =
NULL) => if an error occured during process, a rollback is done and no items are inserted.
If you want to manage your own transaction, you can use a session (
qx::QxSession class) : see here from more details
http://www.qxorm.com/qxorm_en/faq.html#faq_170I think it's the best way for batch processing using QtSql module (but maybe I'm wrong ?).
Note : list of supported container types to pass to
qx::dao::insert() or
qx::dao::update() functions => STL, Qt, boost and qx::QxCollection !
For example :
std::vector,
std::list,
QList,
QVector,
QHash,
boost::unordered_map,
qx::QxCollection, etc...