[Development] Threads and the SQL Module

Łukasz Korbel lkorbel at milosolutions.com
Wed Feb 15 13:37:11 CET 2017


According to
http://doc.qt.io/qt-5/threads-modules.html#threads-and-the-sql-module
database connection should be used within one thread *only*.

I have checked SQLite driver and according to
https://www.sqlite.org/threadsafe.html it supports multithreading by
default. And it seems that Qt implementation does not restrict it (
http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp#n645).
Code I'm working on is creating QSqlQuery for the same connection in
different threads and it works.

I understand it doesn't mean Qt want or need to support such use case but
maybe documentation
can be slightly more accurate? Right now it implies that database
connection can never be used from different threads but it seem it depends
more on particular driver/3rdparty lib.


*Łukasz Korbel *
Senior Software Developer
Email: lkorbel at milosolutions.com
Skype: lukasz_korbel
*Milo Solutions*
www.milosolutions.com | Facebook <https://www.facebook.com/theMiloSolutions>
| Twitter <https://twitter.com/milosolutions>
Disclaimer: This e-mail and any attachments contain information that may be
privileged or confidential and is the property of Milo Solutions. If you
are not the intended recipient, please notify me immediately by replying to
this e-mail, and then delete it. Any unauthorised
dissemination, distribution, copying or use of this communication is
strictly prohibited. The contents of an attachment to this e-mail may
contain software viruses, which could damage your own computer system.
Although this e-mail and any files attached to it may have been checked
with virus detection software before transmission you should carry out your
own virus checks before opening the attachment. No liability can be
accepted for any damage which you may sustain as a result of software
viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170215/07995f1b/attachment.html>


More information about the Development mailing list