John, thank you very much for your answer. I'll study that possibility.

So I would ask what's the exactly purpose of multi-thread support, but
I can't, because I even hadn't read the whole documentation.

Thanks again. Bye!

On 5/13/06, John Stanton <[EMAIL PROTECTED]> wrote:
Your problem is not with threading, that seems to be working just fine,
it is with the way Sqlite works.  Since it is a single file it locks the
entire file when you alter the DB so that only one thread/process can
change it at a time.  You need to rethink your application in such a way
that you use the Sqlite busy logic or use your own synchronization using
a mutex or similar.

Use Sqlite as you would use shared access to a single file using file
locks and then you will reap the benefits of the ease of use and
simplicity of maintenance of Sqlite, otherwise you need to go to a more
complex DBMS.
JS

Silas Justiniano wrote:
> Hello! I've downloaded sqlite-3_3_5-tea and compiled it correctly. It
> generates libsqlite335.so perfectly, but there is a problem.
>
> I compiled it with threads (I did ./configure --enable-thread and I
> checked -DTHREAD_SAFE=1 in the Makefile) but I can't write to the same
> database/table at the same time. I open a transaction in one thread
> and do lots of sql inserctions, then I close. While there is an opened
> transaction in one thread, I can't do (insert/update/delete) anything
> in another thread. I get "database is locked". Any idea?
>
> Here is the script I used to test:
> # --- BEGIN
> package require Thread
>
> load ./libsqlite335.so
> sqlite3 db db
>
> db eval "DROP TABLE tabela;"
> db eval "CREATE TABLE tabela(n integer);"
>
> set thread_id [thread::create {
>  load libsqlite335.so
>  sqlite3 db db
>  set i 0
>
>  db eval "BEGIN DEFERRED TRANSACTION;"
>
>  while 1 {
>    db eval "INSERT INTO tabela VALUES($i);"
>    puts $i
>    incr i
>  }
>
>  db eval "COMMIT TRANSACTION;"
>
>  vwait forever
> }]
>
> set i 10000
> while 1 {
>  db eval "INSERT INTO tabela VALUES($i);"
>  puts $i
>  incr i
> }
> # --- END
>
> See I'm using the Thread extension and Tcl is "thread-compiled"(?).
>
> Any clue?
>
> Thank you! Bye!
>




--
Silas Justiniano - Brazil

Reply via email to