Hello,

I have tried to search all the documentation about threading in SQLite, but
I'm still somewhat confused.

It's often suggested to create a pool of sqlite3 structures, but what if I
would like to have only only sqlite3 connection and serialize all the DB
operations to one thread (name it 'A') that would prepare and execute all
the queries. I guess that this would work well...

However, it would be too time consuming to serialize every call to
sqlite3_step(), so I wonder whether it can be called in another thread. So
my scenario is:

1. Thread B wants to open a query 'SELECT * FROM Tbl1'
2. Thread A is used to prepare the query 'SELECT * FROM Tbl1' using
sqlite3_prepare16_v2() and using the same sqlite3 DB connection as for
possibly some other running SQL statements.
3. Thread B now repeatedly calls sqlite3_step(), sqlite3_column_text16() and
similar functions in order to get all rows from DB.
4. Thread A is used to call sqlite3_finalize() on the openned query.

So my questions are:
a. Would the code described above work.
b. In step 3., do I have to somehow make sure that calls to sqlite3_step()
don't interfere with other SQLite processing in thread A, e.g. by Windows
CriticalSections? Is anything like this also needed for
sqlite3_column_text16()?

Thanks for any explanation,
Jiri

Reply via email to