QT Sql and Threads

This is my situation, requests are made through the browser to my application. Each request is handled by a different thread and in some cases these requests include INSERT, UPDATE, DELETE, in a sqlite database. What I do not understand is how to manage the connection to the db.

For each thread I have to use a new connection (and thus open-close connection) making sure that there are never two connections with the same name? Or should I create a single connection to the DB and I have to use a mutex to avoid concurrency issues? I'm using QTSql library and SQLite as database

Sorry for my bad english.


Connections can only be used from within the thread that did the creation. So I would highly discourage from using a single connection. It also depends on the database driver if it allows concurrent operations.

If you are using transactions you have to keep in mind that transactions for SQLite are not thread-safe in Qt by default (DEFERRED mode). You can init a thread safe transaction manually as far as I know (BEGIN IMMEDIATE TRANSACTION query).

Need Your Help

Changing file permission in perl


I am creating a file with below code :

Extending IPrincipal in WCF service with UseAspNetRoles principal permissions mode

c# asp.net wcf iis

In my WCF webservice web.config I have the following under serviceBehaviors:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.