[Interest] Sqlite "multithreaded" application

Daniël de Kok me at danieldk.eu
Wed Oct 26 10:33:03 CEST 2011


Hi Michele,

On Oct 26, 2011, at 10:07 AM, Michele Ciampichetti wrote:
> I've a problem with QSqlite driver: I create an application that use an SQLite DB by mean of QSqlite Driver. Now. I'd like to makfore it a Network application, in which some user access the same DB from different instances of this  application on different machines.
> I tryed it but, the concurrent access to QSqlite create some mistake.
>  
> This use is possible? Which is the best approach for this? I see that Sqlite3 permit the serialization or multithread approach, how can I activate this on my driver?

In the situation that you sketch, no multi-threading is involved [1], but rather multiple processes accessing the same SQLite database. SQLite uses locking to regulate concurrent access [2]. If the database has a write lock, the driver can retry writing for a given amount of time [3].

That said, SQLite is not really fit for large multi-user applications, you might want to look into alternatives such as PostgreSQL or MySQL.

-- Daniël

[1] If you do intend to use multi-threading: a connection can only be used in the thread that created it.
[2] http://www.sqlite.org/lockingv3.html
[3] http://doc.qt.nokia.com/stable/sql-driver.html#qsqlite-for-sqlite-version-3-and-above




More information about the Interest mailing list