Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

SQLite transactions in multiple threads

$
0
0
Hi Currently I’m using QSqlDatabase::transaction() and QSqlDatabase::commit() to optimize the write operations to a database. Still on large amount of queries the GUI is blocked. So I want to make some of the transactions in a secondary thread. According to http://qt-project.org/doc/qt-4.8/threads-modules.html#threads-and-the-sql-module [qt-project.org] that will be thread-safe if I create and use another database connection in the secondary thread. I have two questions on this: 1) Does it mean that I can use another connection in a secondary thread to the work on the same database file? I suppose that SQLite internally will take care of a situation when 2 threads try to modify the same database file/table, but I’m not sure. 2) Can I use QSqlDatabase::transaction() and QSqlDatabase::commit() concurrently in different threads, using different database connections but to the same database file/table? What confuses me is the note in http://qt-project.org/doc/qt-4.8/qsqldatabase.html#commit. I’m asking this because I want to have two database connections, one in the GUI thread (for the QSqlTableModel) and one in a secondary thread (for writing large queries). Thanks

Viewing all articles
Browse latest Browse all 18427

Trending Articles