Batch inserts/updates

Use this forum to request new features or suggest modifications to existing features

Batch inserts/updates

Postby Davita » Mon Apr 02, 2012 7:37 pm

Hi

It would be nice if QxOrm had support of batch operations. Are you planning to implement that feature in the future? :)

Thanks
Davita
 

Re: Batch inserts/updates

Postby QxOrm admin » Tue Apr 03, 2012 7:31 am

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_170
I 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...
QxOrm admin
 

Re: Batch inserts/updates

Postby Davita » Wed Apr 04, 2012 7:13 am

Great news, thanks :)
Davita
 


Return to QxOrm - Feature request

Who is online

Users browsing this forum: No registered users and 2 guests

cron