[Interest] SQL databases and threading

Tony Rietwyk tony at rightsoft.com.au
Mon Oct 15 06:49:55 CEST 2018


AFAIK, you have to open the QSqlDatabase, do QSqlQuery prepare and exec, 
read the results, do the next query, etc. all within one thread.  You 
can have multiple threads accessing simultaneously, if the underlying 
database supports it.  But you cannot send the query in one thread, then 
read the results in another.

Regards, Tony

On 12/10/2018 5:52 PM, Konstantin Shegunov wrote:
> Hello,
> Is there any way to tell (besides looking at the sources) if a given 
> SQL plugin, or single methods of it, is reentrant/thread safe? The 
> docs are rather evasive on the issue ...
> What would be allowed to do if I want to thread the SQL queries? Can I 
> serialize the exec/prepare and then pull the resultset in another thread?
> Ideally I would like to process the results in a thread if possible, 
> even if I have to serialize the exec.
> Currently I'm working with the PQSQL driver, but general answers are 
> acceptable as well.
> Thanks in advance.
> Kind regards.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181015/a7e76aa3/attachment.html>

More information about the Interest mailing list